wx.lib.ogl.diagram.Diagram¶
The Diagram
encapsulates an entire diagram, with methods for
drawing. A diagram has an associated ShapeCanvas
.
Class Hierarchy¶
Methods Summary¶
Default class constructor. |
|
Add a shape to the diagram. If addAfter is not None, the shape |
|
Clear the specified device context. |
|
Remove and delete all shapes in the diagram. |
|
Draw an outline rectangle on the current device context. |
|
Return the shape for the given identifier. |
|
Return the shape canvas associated with this diagram. |
|
Return the number of shapes in the diagram. |
|
Return the grid spacing. |
|
Return the tolerance within which a mouse move is ignored. |
|
Return quick edit mode. |
|
Return the internal shape list. |
|
Return snap-to-grid mode. |
|
Insert a shape at the front of the shape list. |
|
Recentre all the text that should be centred. |
|
Redraw the shapes in the diagram on the specified device context. |
|
Remove all shapes from the diagram but do not delete the shapes. |
|
Remove the shape from the diagram (non-recursively) but do not |
|
Set the canvas associated with this diagram. |
|
Sets grid spacing. |
|
Set the tolerance within which a mouse move is ignored. |
|
Set quick-edit-mode on of off. |
|
Sets snap-to-grid mode. |
|
Call Show for each shape in the diagram. |
|
‘Snaps’ the coordinate to the nearest grid position, if |
Class API¶
- class Diagram(object)¶
The
Diagram
encapsulates an entire diagram, with methods for drawing. A diagram has an associatedShapeCanvas
.
Methods¶
- __init__(self)¶
Default class constructor.
- AddShape(self, object, addAfter=None)¶
Add a shape to the diagram. If addAfter is not None, the shape will be added after addAfter.
- Parameters:
object – an instance of
Shape
addAfter – an instance of
Shape
- Clear(self, dc)¶
Clear the specified device context.
- DeleteAllShapes(self)¶
Remove and delete all shapes in the diagram.
- DrawOutline(self, dc, x1, y1, x2, y2)¶
Draw an outline rectangle on the current device context.
- Parameters:
dc – the
wx.MemoryDC
device contextx1 – the x1 position
y2 – the y2 position
x1 – the x1 position
y2 – the y2 position
- FindShape(self, id)¶
Return the shape for the given identifier.
- Parameters:
id – the shape id to find
- GetCanvas(self)¶
Return the shape canvas associated with this diagram.
- GetCount(self)¶
Return the number of shapes in the diagram.
- GetGridSpacing(self)¶
Return the grid spacing.
- GetMouseTolerance(self)¶
Return the tolerance within which a mouse move is ignored.
- GetQuickEditMode(self)¶
Return quick edit mode.
- GetShapeList(self)¶
Return the internal shape list.
- GetSnapToGrid(self)¶
Return snap-to-grid mode.
- InsertShape(self, object)¶
Insert a shape at the front of the shape list.
- Parameters:
object – an instance of
Shape
- RecentreAll(self, dc)¶
Recentre all the text that should be centred.
- Parameters:
dc – the
wx.MemoryDC
device context
- Redraw(self, dc)¶
Redraw the shapes in the diagram on the specified device context.
- RemoveAllShapes(self)¶
Remove all shapes from the diagram but do not delete the shapes.
- RemoveShape(self, object)¶
Remove the shape from the diagram (non-recursively) but do not delete it.
- Parameters:
object – an instance of
Shape
- SetCanvas(self, canvas)¶
Set the canvas associated with this diagram.
- Parameters:
canvas – an instance of
Canvas
- SetGridSpacing(self, spacing)¶
Sets grid spacing.
- Parameters:
spacing – the spacing
- SetMouseTolerance(self, tolerance)¶
Set the tolerance within which a mouse move is ignored.
The default is 3 pixels.
- Parameters:
tolerance – the tolerance level
- SetQuickEditMode(self, mode)¶
Set quick-edit-mode on of off.
In this mode, refreshes are minimized, but the diagram may need manual refreshing occasionally.
- Parameters:
mode – True to quick edit or False for normal edit
- SetSnapToGrid(self, snap)¶
Sets snap-to-grid mode.
- Parameters:
snap – True to snap to grid or False not to snap
- ShowAll(self, show)¶
Call Show for each shape in the diagram.
- Parameters:
show –
True
or False
- Snap(self, x, y)¶
‘Snaps’ the coordinate to the nearest grid position, if snap-to-grid is on.
- Parameters:
x – the x position
y – the y position