SDS2 Parametric API
 All Classes Namespaces Functions Variables Pages
List of all members
diagram.DiagramBuilder.DiagramBuilder Class Reference

This class is a wrapper for Tkinter.Canvas that provides a few additional features: More...

Methods defined here:

def AddBinding
def AddItem
def ClearHighlight
def ClearHover
def Erase
def EraseAll
def Hide
def HideGrid
def Highlight
def Hover
def Raise
def Render
def SetBounds
def SetScaleAdjustment
def Show
def ShowGrid
def __init__

Data and other attributes defined here:

string grid_tag = 'GRID'

Detailed Description

This class is a wrapper for Tkinter.Canvas that provides a few additional features:

1) Automatic scaling and centering of the diagram. This allows the caller to draw a diagram in whatever units are most natural (e.g. inches) without having to worry about converting to pixels or drawing within the bounds of the canvas. When rendered the DiagramBuilder will scale the drawing to fit with in the specified boundary and center it.

2) A simple interface for highlighting items within the diagram. On forms this can be used on Focus In of a widget to highlight what the widget's value affects.

3) An extensible framework that allows for adding additional item types.

Diagrams are created by supplying DiagramItems to the DiagramBuilder. Currently there are DiagramItems for the most commonly used canvas items (arc, line, oval, polygon, rectangle, text) as well as a few more complex items (dimension, labeled arrow).

See the following for usage: plugins/HollowCoreSlab/HollowCoreSlabEdit.py plugins/ConcreteTee/ConcreteTeeEdit.py

Constructor & Destructor Documentation

def diagram.DiagramBuilder.DiagramBuilder.__init__ (   args)
 Creates a DiagramBuilder instance.
 Parameters:
 canvas: The TkInter canvas object that this DiagrameBuilder is to manage.

Member Function Documentation

def diagram.DiagramBuilder.DiagramBuilder.AddBinding (   args)
 Adds a binding to items in the diagram with the specified tag. This 
 should only be called before Render().
 Parameters:
 tag: The tag for items to bind.
 event: The event sequence (e.g. <Button-1>, <Enter>).
 command: A function that executes the action to take when the event fires.
     Command function signature should be:
     def callback(tag, event):
 
 Example:
 builder = DiagramBuilder( canvas )
 tag = 'MyCircle'
 builder.AddItem( OvalItem.Circle( (0., 0.), 5.), [tag] )
 
 def onCircleClick(tag, event):
     print 'Clicked circle with tag ' + tag
     
 builder.AddBinding( tag, '<Button-1>', onCircleClick )
def diagram.DiagramBuilder.DiagramBuilder.AddItem (   args)
 Adds an item to be drawn on the diagram. This should only be called
 before Render()
 Parameters:
 diagramItem: An object that inherits from DiagramItem.
 tags: A list of tags to associate the diagram item with.  The tag list 
 may be empty if the highlight or hover functionality is not needed for the 
 diagram item. The first tag should be the most specific tag (i.e. should 
 usually only be associated with this drawing item).
def diagram.DiagramBuilder.DiagramBuilder.ClearHighlight (   args)
 Clears all highlights from the diagram.
def diagram.DiagramBuilder.DiagramBuilder.ClearHover (   args)
 ClearHover(args)
def diagram.DiagramBuilder.DiagramBuilder.Erase (   args)
 Erase(args)
def diagram.DiagramBuilder.DiagramBuilder.EraseAll (   args)
 Erases everything that this object has added to the canvas.
def diagram.DiagramBuilder.DiagramBuilder.Hide (   args)
 Hide(args)
def diagram.DiagramBuilder.DiagramBuilder.HideGrid (   args)
 HideGrid(args)
def diagram.DiagramBuilder.DiagramBuilder.Highlight (   args)
 Highlights all diagram items that are associated with the specified tag.
def diagram.DiagramBuilder.DiagramBuilder.Hover (   args)
 Hover(args)
def diagram.DiagramBuilder.DiagramBuilder.Raise (   args)
 Raises the drawing items that are associated with the specified tag to 
 the top of the canvas.
def diagram.DiagramBuilder.DiagramBuilder.Render (   args)
 Renders the diagram automatically scaling and centering it within the 
 diagram bounds.
def diagram.DiagramBuilder.DiagramBuilder.SetBounds (   args)
 Sets the boundary in which the diagram should be drawn. Defaults to the 
 bounds of the canvas at the time this object is created. This should only
 be called before Render().
 Parameters:
 left: The x-coordinate of the left edge of the boundary.
 right: The x-coordinate of the right edge of the boundary.
 top: The y-coordinate of the top edge of the boundary.
 bottom: The y-coordinate of the bottom edge of the boundary.
def diagram.DiagramBuilder.DiagramBuilder.SetScaleAdjustment (   args)
 Sets the scale adjustment.  This should only be called before Render(). 
 Parameters:
 pcnt: The scale adjustment percentage. Less than 1. will make the diagram
 smaller.  Greater than 1. will make it larger.  0. or negative values are
 not allowed.
def diagram.DiagramBuilder.DiagramBuilder.Show (   args)
 Show(args)
def diagram.DiagramBuilder.DiagramBuilder.ShowGrid (   args)
 ShowGrid(args)

Member Data Documentation

string diagram.DiagramBuilder.DiagramBuilder.grid_tag = 'GRID'
static