Table Of Contents

Previous topic

RectangleShape

Next topic

ShapeEvtHandler

This Page

phoenix_title Shape

OGL base class

Shape(canvas = None)

The wxShape is the top-level, abstract object that all other objects are derived from. All common functionality is represented by wxShape’s members, and overriden members that appear in derived classes and have behaviour as documented for wxShape, are not documented separately.


class_hierarchy Inheritance Diagram

Inheritance diagram for class Shape

Inheritance diagram of Shape


method_summary Methods Summary

__init__  
AddLine Add a line between this shape and the given other shape, at the
AddRegion Add a region to the shape.
AddText Add a line of text to the shape’s default text region.
AddToCanvas Add the shape to the canvas’s shape list.
AncestorSelected TRUE if the shape’s ancestor is currently selected.
ApplyAttachmentOrdering Apply the line ordering in linesToSort to the shape, to reorder
AssignNewIds Assign new ids to this image and its children.
Attach Set the shape’s internal canvas pointer to point to the given canvas.
AttachmentIsValid TRUE if attachment is a valid attachment point.
AttachmentSortTest Return TRUE if pt1 is less than or equal to pt2, in the sense
CalcSimpleAttachment Assuming the attachment lies along a vertical or horizontal line,
ClearAttachments Clear internal custom attachment point shapes (of class
ClearRegions Clear the ShapeRegions from the shape.
ClearText Clear the text from the specified text region.
Delete Fully disconnect this shape from parents, children, the
DeleteControlPoints Delete the control points (or handles) for the shape.
Detach Disassociates the shape from its canvas.
Draggable TRUE if the shape may be dragged by the user.
Draw Draw the whole shape and any lines attached to it.
DrawContents Draw the internal graphic of the shape (such as text).
DrawLinks Draws any lines linked to this shape.
Erase Erase the shape.
EraseContents Erase the shape contents, that is, the area within the shape’s
EraseLinks Erase links attached to this shape, but do not repair damage
FindRegion Find the actual image (‘this’ if non-composite) and region id
FindRegionNames Get a list of all region names for this image (composite or simple).
Flash Flash the shape.
FormatText Reformat the given text region; defaults to formatting the
GetAttachmentLineCount Get the number of lines at this attachment position.
GetAttachmentMode Return the attachment mode.
GetAttachmentPosition Get the position at which the given attachment point should be drawn.
GetAttachmentPositionEdge Only get the attachment position at the _edge_ of the shape,
GetBackgroundBrush Return brush of the right colour for the background.
GetBackgroundPen Return pen of the right colour for the background.
GetBoundingBoxMax Get the maximum bounding box for the shape, taking into account
GetBoundingBoxMin Get the minimum bounding box for the shape, that defines the area
GetBranchingAttachmentInfo Get information about where branching connections go.
GetBranchingAttachmentPoint  
GetBranchingAttachmentRoot Get the root point at the given attachment.
GetBranchStyle  
GetBrush Return the brush used for filling the shape.
GetCanvas Get the internal canvas.
GetCentreResize TRUE if the shape is to be resized from the centre (the centre stands
GetChildren Return the list of children for this shape.
GetClassName  
GetDisableLabel TRUE if the default region will not be shown, FALSE otherwise.
GetDrawHandles Return the list of drawhandles.
GetEventHandler Return the event handler for this shape.
GetFixedHeight TRUE if the shape cannot be resized in the vertical plane.
GetFixedSize Return flags indicating whether the shape is of fixed size in
GetFixedWidth TRUE if the shape cannot be resized in the horizontal plane.
GetFont Get the font for the specified text region.
GetFormatMode  
GetId Return the integer identifier for this shape.
GetLinePosition Get the zero-based position of line in the list of lines
GetLines Return the list of lines connected to this shape.
GetMaintainAspectRatio TRUE if shape keeps aspect ratio during resize.
GetNumberOfAttachments Get the number of attachment points for this shape.
GetNumberOfTextRegions Return the number of text regions for this shape.
GetParent Return the parent of this shape, if it is part of a composite.
GetPen Return the pen used for drawing the shape’s outline.
GetPerimeterPoint Get the point at which the line from (x1, y1) to (x2, y2) hits
GetRegionId Get the region’s identifier by name.
GetRegionName Get the region’s name.
GetRegions Return the list of ShapeRegions.
GetRotation Return the angle of rotation in radians.
GetSensitivityFilter Return the sensitivity filter, a bitlist of values.
GetShadowMode Return the current shadow mode setting
GetSpaceAttachments Return whether lines should be spaced out evenly at the point they
GetTextColour Get the colour for the specified text region.
GetTopAncestor Return the top-most ancestor of this shape (the root of
GetX Get the x position of the centre of the shape.
GetY Get the y position of the centre of the shape.
HasDescendant TRUE if image is a descendant of this composite.
HitTest Given a point on a canvas, returns TRUE if the point was on the
InsertInCanvas Insert the shape at the front of the shape list of canvas.
IsHighlighted TRUE if the shape is highlighted. Shape highlighting is unimplemented.
IsShown TRUE if the shape is in a visible state, FALSE otherwise.
LogicalToPhysicalAttachment Rotate the standard attachment point from logical
MakeControlPoints Make a list of control points (draggable handles) appropriate to
MakeMandatoryControlPoints Make the mandatory control points.
Move Move the shape to the given position.
MoveLineToNewAttachment Move the given line (which must already be attached to the shape)
MoveLinks Redraw all the lines attached to the shape.
NameRegions Make unique names for all the regions in a shape or composite shape.
OnBeginDragLeft  
OnBeginDragRight  
OnChangeAttachment  
OnDragLeft  
OnDragRight  
OnDraw  
OnDrawBranches  
OnDrawBranchesAttachment  
OnDrawContents  
OnDrawControlPoints  
OnDrawOutline  
OnEndDragLeft  
OnEndDragRight  
OnErase  
OnEraseContents  
OnEraseControlPoints  
OnHighlight  
OnLeftClick  
OnMoveLinks  
OnMovePre  
OnRightClick  
OnSize  
OnSizingBeginDragLeft  
OnSizingDragLeft  
OnSizingEndDragLeft  
PhysicalToLogicalAttachment Rotate the standard attachment point from physical
Recentre Do recentring (or other formatting) for all the text regions
Recompute Recomputes any constraints associated with the shape.
RemoveFromCanvas Remove the shape from the canvas.
RemoveLine Remove the given line from the shape’s list of attached lines.
ResetControlPoints Reset the positions of the control points (for instance when the
ResetMandatoryControlPoints Reset the mandatory control points.
Rotate Rotate about the given axis by the given amount in radians.
Select Select or deselect the given shape, drawing or erasing control points
Selected TRUE if the shape is currently selected.
SetAttachmentMode Set the attachment mode.
SetAttachmentSize  
SetBrush Set the brush for filling the shape’s shape.
SetCanvas Identical to Shape.Attach.
SetCentreResize Specify whether the shape is to be resized from the centre (the
SetDefaultRegionSize Set the default region to be consistent with the shape size.
SetDisableLabel Set flag to TRUE to stop the default region being shown.
SetDraggable Set the shape to be draggable or not draggable.
SetDrawHandles Set the drawHandles flag for this shape and all descendants.
SetEventHandler Set the event handler for this shape.
SetFixedSize Set the shape to be fixed size.
SetFont Set the font for the specified text region.
SetFormatMode Set the format mode of the default text region. The argument
SetHighlight Set the highlight for a shape. Shape highlighting is unimplemented.
SetId Set the integer identifier for this shape.
SetMaintainAspectRatio Set whether a shape that resizes should not change the aspect ratio
SetParent  
SetPen Set the pen for drawing the shape’s outline.
SetRegionName Set the name for this region.
SetRotation  
SetSensitivityFilter Set the shape to be sensitive or insensitive to specific mouse
SetShadowMode Set the shadow mode (whether a shadow is drawn or not).
SetShape  
SetSize Set the shape’s size.
SetSpaceAttachments Indicate whether lines should be spaced out evenly at the point
SetTextColour Set the colour for the specified text region.
SetX Set the x position of the shape.
SetY Set the y position of the shape.
Show Set a flag indicating whether the shape should be drawn.
SortLines Reorder the lines coming into the node image at this attachment

api Class API



class Shape(ShapeEvtHandler)

OGL base class

Shape(canvas = None)

The wxShape is the top-level, abstract object that all other objects are derived from. All common functionality is represented by wxShape’s members, and overriden members that appear in derived classes and have behaviour as documented for wxShape, are not documented separately.


Methods



__init__(self, canvas = None)


AddLine(self, line, other, attachFrom = 0, attachTo = 0, positionFrom = -1, positionTo = -1)

Add a line between this shape and the given other shape, at the specified attachment points.

The position in the list of lines at each end can also be specified, so that the line will be drawn at a particular point on its attachment point.



AddRegion(self, region)

Add a region to the shape.



AddText(self, string)

Add a line of text to the shape’s default text region.



AddToCanvas(self, theCanvas, addAfter = None)

Add the shape to the canvas’s shape list. If addAfter is not None, will add the shape after this one.



AncestorSelected(self)

TRUE if the shape’s ancestor is currently selected.



ApplyAttachmentOrdering(self, linesToSort)

Apply the line ordering in linesToSort to the shape, to reorder the way lines are attached.



AssignNewIds(self)

Assign new ids to this image and its children.



Attach(self, can)

Set the shape’s internal canvas pointer to point to the given canvas.



AttachmentIsValid(self, attachment)

TRUE if attachment is a valid attachment point.



AttachmentSortTest(self, attachmentPoint, pt1, pt2)

Return TRUE if pt1 is less than or equal to pt2, in the sense that one point comes before another on an edge of the shape.

attachment is the attachment point (side) in question.

This function is used in Shape.MoveLineToNewAttachment to determine the new line ordering.



CalcSimpleAttachment(self, pt1, pt2, nth, noArcs, line)

Assuming the attachment lies along a vertical or horizontal line, calculate the position on that point.

Parameters:

pt1
The first point of the line repesenting the edge of the shape.
pt2
The second point of the line representing the edge of the shape.
nth
The position on the edge (for example there may be 6 lines at this attachment point, and this may be the 2nd line.
noArcs
The number of lines at this edge.
line
The line shape.

Remarks

This function expects the line to be either vertical or horizontal, and determines which.



ClearAttachments(self)

Clear internal custom attachment point shapes (of class wxAttachmentPoint).



ClearRegions(self)

Clear the ShapeRegions from the shape.



ClearText(self, regionId = 0)

Clear the text from the specified text region.



Delete(self)

Fully disconnect this shape from parents, children, the canvas, etc.



DeleteControlPoints(self, dc = None)

Delete the control points (or handles) for the shape.

Does not redraw the shape.



Detach(self)

Disassociates the shape from its canvas.



Draggable(self)

TRUE if the shape may be dragged by the user.



Draw(self, dc)

Draw the whole shape and any lines attached to it.

Do not override this function: override OnDraw, which is called by this function.



DrawContents(self, dc)

Draw the internal graphic of the shape (such as text).

Do not override this function: override OnDrawContents, which is called by this function.



Draws any lines linked to this shape.



Erase(self, dc)

Erase the shape. Does not repair damage caused to other shapes.



EraseContents(self, dc)

Erase the shape contents, that is, the area within the shape’s minimum bounding box.



Erase links attached to this shape, but do not repair damage caused to other shapes.



FindRegion(self, name)

Find the actual image (‘this’ if non-composite) and region id for the given region name.



FindRegionNames(self)

Get a list of all region names for this image (composite or simple).



Flash(self)

Flash the shape.



FormatText(self, dc, s, i = 0)

Reformat the given text region; defaults to formatting the default region.



GetAttachmentLineCount(self, attachment)

Get the number of lines at this attachment position.



GetAttachmentMode(self)

Return the attachment mode.

See Shape.SetAttachmentMode.



GetAttachmentPosition(self, attachment, nth = 0, no_arcs = 1, line = None)

Get the position at which the given attachment point should be drawn.

If attachment isn’t found among the attachment points of the shape, returns None.



GetAttachmentPositionEdge(self, attachment, nth = 0, no_arcs = 1, line = None)

Only get the attachment position at the _edge_ of the shape, ignoring branching mode. This is used e.g. to indicate the edge of interest, not the point on the attachment branch.



GetBackgroundBrush(self)

Return brush of the right colour for the background.



GetBackgroundPen(self)

Return pen of the right colour for the background.



GetBoundingBoxMax(self)

Get the maximum bounding box for the shape, taking into account external features such as shadows.



GetBoundingBoxMin(self)

Get the minimum bounding box for the shape, that defines the area available for drawing the contents (such as text).

Must be overridden.



GetBranchingAttachmentInfo(self, attachment)

Get information about where branching connections go.

Returns FALSE if there are no lines at this attachment.



GetBranchingAttachmentPoint(self, attachment, n)


GetBranchingAttachmentRoot(self, attachment)

Get the root point at the given attachment.



GetBranchStyle(self)


GetBrush(self)

Return the brush used for filling the shape.



GetCanvas(self)

Get the internal canvas.



GetCentreResize(self)

TRUE if the shape is to be resized from the centre (the centre stands still), or FALSE if from the corner or side being dragged (the other corner or side stands still)



GetChildren(self)

Return the list of children for this shape.



GetClassName(self)


GetDisableLabel(self)

TRUE if the default region will not be shown, FALSE otherwise.



GetDrawHandles(self)

Return the list of drawhandles.



GetEventHandler(self)

Return the event handler for this shape.



GetFixedHeight(self)

TRUE if the shape cannot be resized in the vertical plane.



GetFixedSize(self)

Return flags indicating whether the shape is of fixed size in either direction.



GetFixedWidth(self)

TRUE if the shape cannot be resized in the horizontal plane.



GetFont(self, regionId = 0)

Get the font for the specified text region.



GetFormatMode(self, regionId = 0)


GetId(self)

Return the integer identifier for this shape.



GetLinePosition(self, line)

Get the zero-based position of line in the list of lines for this shape.



GetLines(self)

Return the list of lines connected to this shape.



GetMaintainAspectRatio(self)

TRUE if shape keeps aspect ratio during resize.



GetNumberOfAttachments(self)

Get the number of attachment points for this shape.



GetNumberOfTextRegions(self)

Return the number of text regions for this shape.



GetParent(self)

Return the parent of this shape, if it is part of a composite.



GetPen(self)

Return the pen used for drawing the shape’s outline.



GetPerimeterPoint(self, x1, y1, x2, y2)

Get the point at which the line from (x1, y1) to (x2, y2) hits the shape. Returns False if the line doesn’t hit the perimeter.



GetRegionId(self, name)

Get the region’s identifier by name. This is not unique for within an entire composite, but is unique for the image.



GetRegionName(self, regionId = 0)

Get the region’s name. A region’s name can be used to uniquely determine a region within an entire composite image hierarchy. See also Shape.SetRegionName.



GetRegions(self)

Return the list of ShapeRegions.



GetRotation(self)

Return the angle of rotation in radians.



GetSensitivityFilter(self)

Return the sensitivity filter, a bitlist of values.

See Shape.SetSensitivityFilter.



GetShadowMode(self)

Return the current shadow mode setting



GetSpaceAttachments(self)

Return whether lines should be spaced out evenly at the point they touch the node (True), or whether they should join at a single point (False).



GetTextColour(self, regionId = 0)

Get the colour for the specified text region.



GetTopAncestor(self)

Return the top-most ancestor of this shape (the root of the composite).



GetX(self)

Get the x position of the centre of the shape.



GetY(self)

Get the y position of the centre of the shape.



HasDescendant(self, image)

TRUE if image is a descendant of this composite.



HitTest(self, x, y)

Given a point on a canvas, returns TRUE if the point was on the shape, and returns the nearest attachment point and distance from the given point and target.



InsertInCanvas(self, theCanvas)

Insert the shape at the front of the shape list of canvas.



IsHighlighted(self)

TRUE if the shape is highlighted. Shape highlighting is unimplemented.



IsShown(self)

TRUE if the shape is in a visible state, FALSE otherwise.

Note that this has nothing to do with whether the window is hidden or the shape has scrolled off the canvas; it refers to the internal visibility flag.



LogicalToPhysicalAttachment(self, logicalAttachment)

Rotate the standard attachment point from logical to physical (0 is always North).



MakeControlPoints(self)

Make a list of control points (draggable handles) appropriate to the shape.



MakeMandatoryControlPoints(self)

Make the mandatory control points.

For example, the control point on a dividing line should appear even if the divided rectangle shape’s handles should not appear (because it is the child of a composite, and children are not resizable).



Move(self, dc, x, y, display = True)

Move the shape to the given position. Redraw if display is TRUE.



MoveLineToNewAttachment(self, dc, to_move, x, y)

Move the given line (which must already be attached to the shape) to a different attachment point on the shape, or a different order on the same attachment.

Calls Shape.AttachmentSortTest and then ShapeEvtHandler.OnChangeAttachment.



Redraw all the lines attached to the shape.



NameRegions(self, parentName="")

Make unique names for all the regions in a shape or composite shape.



OnBeginDragLeft(self, x, y, keys = 0, attachment = 0)


OnBeginDragRight(self, x, y, keys = 0, attachment = 0)


OnChangeAttachment(self, attachment, line, ordering)


OnDragLeft(self, draw, x, y, keys = 0, attachment = 0)


OnDragRight(self, draw, x, y, keys = 0, attachment = 0)


OnDraw(self, dc)


OnDrawBranches(self, dc, erase = False)


OnDrawBranchesAttachment(self, dc, attachment, erase = False)


OnDrawContents(self, dc)


OnDrawControlPoints(self, dc)


OnDrawOutline(self, dc, x, y, w, h)


OnEndDragLeft(self, x, y, keys = 0, attachment = 0)


OnEndDragRight(self, x, y, keys = 0, attachment = 0)


OnErase(self, dc)


OnEraseContents(self, dc)


OnEraseControlPoints(self, dc)


OnHighlight(self, dc)


OnLeftClick(self, x, y, keys = 0, attachment = 0)




OnMovePre(self, dc, x, y, old_x, old_y, display = True)


OnRightClick(self, x, y, keys = 0, attachment = 0)


OnSize(self, x, y)


OnSizingBeginDragLeft(self, pt, x, y, keys = 0, attachment = 0)


OnSizingDragLeft(self, pt, draw, x, y, keys = 0, attachment = 0)


OnSizingEndDragLeft(self, pt, x, y, keys = 0, attachment = 0)


PhysicalToLogicalAttachment(self, physicalAttachment)

Rotate the standard attachment point from physical (0 is always North) to logical (0 -> 1 if rotated by 90 degrees)



Recentre(self, dc)

Do recentring (or other formatting) for all the text regions for this shape.



Recompute(self)

Recomputes any constraints associated with the shape.

Normally applicable to CompositeShapes only, but harmless for other classes of Shape.



RemoveFromCanvas(self, theCanvas)

Remove the shape from the canvas.



RemoveLine(self, line)

Remove the given line from the shape’s list of attached lines.



ResetControlPoints(self)

Reset the positions of the control points (for instance when the shape’s shape has changed).



ResetMandatoryControlPoints(self)

Reset the mandatory control points.



Rotate(self, x, y, theta)

Rotate about the given axis by the given amount in radians.



Select(self, select, dc = None)

Select or deselect the given shape, drawing or erasing control points (handles) as necessary.



Selected(self)

TRUE if the shape is currently selected.



SetAttachmentMode(self, mode)

Set the attachment mode.

If TRUE, attachment points will be significant when drawing lines to and from this shape. If FALSE, lines will be drawn as if to the centre of the shape.



SetAttachmentSize(self, w, h)


SetBrush(self, the_brush)

Set the brush for filling the shape’s shape.



SetCanvas(self, theCanvas)

Identical to Shape.Attach.



SetCentreResize(self, cr)

Specify whether the shape is to be resized from the centre (the centre stands still) or from the corner or side being dragged (the other corner or side stands still).



SetDefaultRegionSize(self)

Set the default region to be consistent with the shape size.



SetDisableLabel(self, flag)

Set flag to TRUE to stop the default region being shown.



SetDraggable(self, drag, recursive = False)

Set the shape to be draggable or not draggable.



SetDrawHandles(self, drawH)

Set the drawHandles flag for this shape and all descendants. If drawH is TRUE (the default), any handles (control points) will be drawn. Otherwise, the handles will not be drawn.



SetEventHandler(self, handler)

Set the event handler for this shape.



SetFixedSize(self, x, y)

Set the shape to be fixed size.



SetFont(self, the_font, regionId = 0)

Set the font for the specified text region.



SetFormatMode(self, mode, regionId = 0)

Set the format mode of the default text region. The argument can be a bit list of the following:

FORMAT_NONE
No formatting.
FORMAT_CENTRE_HORIZ
Horizontal centring.
FORMAT_CENTRE_VERT
Vertical centring.


SetHighlight(self, hi, recurse = False)

Set the highlight for a shape. Shape highlighting is unimplemented.



SetId(self, i)

Set the integer identifier for this shape.



SetMaintainAspectRatio(self, ar)

Set whether a shape that resizes should not change the aspect ratio (width and height should be in the original proportion).



SetParent(self, p)


SetPen(self, the_pen)

Set the pen for drawing the shape’s outline.



SetRegionName(self, name, regionId = 0)

Set the name for this region. The name for a region is unique within the scope of the whole composite, whereas a region id is unique only for a single image.



SetRotation(self, rotation)


SetSensitivityFilter(self, sens = OP_ALL, recursive = False)

Set the shape to be sensitive or insensitive to specific mouse operations.

sens is a bitlist of the following:

  • OP_CLICK_LEFT
  • OP_CLICK_RIGHT
  • OP_DRAG_LEFT
  • OP_DRAG_RIGHT
  • OP_ALL (equivalent to a combination of all the above).


SetShadowMode(self, mode, redraw = False)

Set the shadow mode (whether a shadow is drawn or not). mode can be one of the following:

SHADOW_NONE
No shadow (the default).
SHADOW_LEFT
Shadow on the left side.
SHADOW_RIGHT
Shadow on the right side.


SetShape(self, sh)


SetSize(self, x, y, recursive = True)

Set the shape’s size.



SetSpaceAttachments(self, sp)

Indicate whether lines should be spaced out evenly at the point they touch the node (sp = True), or whether they should join at a single point (sp = False).



SetTextColour(self, the_colour, regionId = 0)

Set the colour for the specified text region.



SetX(self, x)

Set the x position of the shape.



SetY(self, y)

Set the y position of the shape.



Show(self, show)

Set a flag indicating whether the shape should be drawn.



SortLines(self, attachment, linesToSort)

Reorder the lines coming into the node image at this attachment position, in the order in which they appear in linesToSort.

Any remaining lines not in the list will be added to the end.