The Shape
is the base class for OGL shapes.
The Shape
is the top-level, abstract object that all other objects
are derived from. All common functionality is represented by Shape
members, and overridden members that appear in derived classes and have
behaviour as documented for Shape
, are not documented separately.
wx.lib.ogl.basic.EllipseShape
, wx.lib.ogl.basic.PolygonShape
, wx.lib.ogl.basic.RectangleShape
, wx.lib.ogl.lines.LineShape
wx.lib.ogl.basic.ShapeEvtHandler
Default class constructor. |
|
Add a line between this shape and the given other shape, at the |
|
Add a region to the shape. |
|
Add a line of text to the shape’s default text region. |
|
Add the shape to the canvas’s shape list. |
|
True if the shape’s ancestor is currently selected. |
|
Apply the line ordering in linesToSort to the shape, to reorder |
|
Assign new ids to this image and its children. |
|
Set the shape’s internal canvas pointer to point to the given canvas. |
|
True if attachment is a valid attachment point. |
|
Return TRUE if pt1 is less than or equal to pt2, in the sense |
|
Assuming the attachment lies along a vertical or horizontal line, |
|
Clear internal custom attachment point shapes (of class |
|
Clear the ShapeRegions from the shape. |
|
Clear the text from the specified text region. |
|
Fully disconnect this shape from parents, children, the |
|
Delete the control points (or handles) for the shape. |
|
Disassociates the shape from its canvas. |
|
Is shape draggable? |
|
Draw the whole shape and any lines attached to it. |
|
Draw the internal graphic of the shape (such as text). |
|
Draws any lines linked to this shape. |
|
Erase the shape. |
|
Erase the shape contents, that is, the area within the shape’s |
|
Erase links attached to this shape, but do not repair damage |
|
Find the actual image (‘this’ if non-composite) and region id |
|
Get a list of all region names for this image (composite or simple). |
|
Flash the shape. |
|
Reformat the given text region; defaults to formatting the |
|
Get the number of lines at this attachment position. |
|
Get the attachment mode. |
|
Get the position at which the given attachment point should be drawn. |
|
Only get the attachment position at the _edge_ of the shape, |
|
Return brush of the right colour for the background. |
|
Return pen of the right colour for the background. |
|
Get the maximum bounding box for the shape, taking into account |
|
Get the minimum bounding box for the shape, that defines the area |
|
Get information about where branching connections go. |
|
Get branching attachment point. |
|
Get the root point at the given attachment. |
|
Get the branch style. |
|
Get the brush used for filling the shape. |
|
Get the internal canvas. |
|
True if the shape is to be resized from the centre (the centre stands |
|
Get the list of children for this shape. |
|
True if the default region will not be shown, False otherwise. |
|
Get the list of drawhandles. |
|
Get the event handler for this shape. |
|
True if the shape cannot be resized in the vertical plane. |
|
Return flags indicating whether the shape is of fixed size in |
|
True if the shape cannot be resized in the horizontal plane. |
|
Get the font for the specified text region. |
|
Get the format mode. |
|
Get the integer identifier for this shape. |
|
Get the zero-based position of line in the list of lines |
|
Return the list of lines connected to this shape. |
|
True if shape keeps aspect ratio during resize. |
|
Get the number of attachment points for this shape. |
|
Get the number of text regions for this shape. |
|
Get the parent of this shape, if it is part of a composite. |
|
Get the pen used for drawing the shape’s outline. |
|
Get the point at which the line from (x1, y1) to (x2, y2) hits |
|
Get the region’s identifier by name. |
|
Get the region’s name. |
|
Get the list of ShapeRegions. |
|
Return the angle of rotation in radians. |
|
Get the sensitivity filter, a bitlist of values. |
|
Get the current shadow mode setting. |
|
Get whether lines should be spaced out evenly at the point they |
|
Get the colour for the specified text region. |
|
Return the top-most ancestor of this shape (the root of |
|
Get the x position of the centre of the shape. |
|
Get the y position of the centre of the shape. |
|
Is image a descendant of this composite. |
|
Given a point on a canvas, returns True if the point was on the |
|
Insert the shape at the front of the shape list of canvas. |
|
True if the shape is highlighted. Shape highlighting is unimplemented. |
|
True if the shape is in a visible state, False otherwise. |
|
Rotate the standard attachment point from logical |
|
Make a list of control points (draggable handles) appropriate to |
|
Make the mandatory control points. |
|
Move the shape to the given position. |
|
Move the given line (which must already be attached to the shape) |
|
Redraw all the lines attached to the shape. |
|
Make unique names for all the regions in a shape or composite shape. |
|
The begin drag left handler. |
|
The begin drag right handler. |
|
Change attachment handler. |
|
The drag left handler. |
|
The drag right handler. |
|
not implemented??? |
|
The draw branches handler. |
|
The draw branches attachment handler. |
|
The draw contents handler. |
|
The draw control points handler. |
|
The draw outline handler. |
|
The end drag left handler. |
|
The end drag right handler. |
|
The erase handler. |
|
The erase contents handler. |
|
The erase control points handler. |
|
not implemented??? |
|
The left click handler. |
|
The move links handler. |
|
The pre move handler. |
|
The right click handler. |
|
not implemented??? |
|
The sizing begin drag left handler. |
|
The sizing drag left handler. |
|
The sizing end drag left handler. |
|
Rotate the standard attachment point from physical |
|
Recentre (or other formatting) all the text regions for this shape. |
|
Recomputes any constraints associated with the shape. |
|
Remove the shape from the canvas. |
|
Remove the given line from the shape’s list of attached lines. |
|
Reset the positions of the control points (for instance when the |
|
Reset the mandatory control points. |
|
Rotate about the given axis by the given amount in radians. |
|
Select or deselect the given shape, drawing or erasing control points |
|
True if the shape is currently selected. |
|
Set the attachment mode. |
|
Set the attachment size. |
|
Set the brush for filling the shape’s shape. |
|
Set the canvas, identical to Shape.Attach. |
|
Specify whether the shape is to be resized from the centre (the |
|
Set the default region to be consistent with the shape size. |
|
Set flag to True to stop the default region being shown. |
|
Set the shape to be draggable or not draggable. |
|
Set the drawHandles flag for this shape and all descendants. |
|
Set the event handler for this shape. |
|
Set the shape to be fixed size. |
|
Set the font for the specified text region. |
|
Set the format mode of the region. |
|
Set the highlight for a shape. Shape highlighting is unimplemented. |
|
Set the integer identifier for this shape. |
|
Set whether a shape that resizes should not change the aspect ratio |
|
Set the parent |
|
Set the pen for drawing the shape’s outline. |
|
Set the name for this region. |
|
Set rotation |
|
Set the shape to be sensitive or insensitive to specific mouse |
|
Set the shadow mode (whether a shadow is drawn or not). |
|
Set shape ??? |
|
Set the shape’s size. |
|
Indicate whether lines should be spaced out evenly at the point |
|
Set the colour for the specified text region. |
|
Set the x position of the shape. |
|
Set the y position of the shape. |
|
Set a flag indicating whether the shape should be drawn. |
|
Reorder the lines coming into the node image at this attachment |
Shape
(ShapeEvtHandler)¶The Shape
is the base class for OGL shapes.
The Shape
is the top-level, abstract object that all other objects
are derived from. All common functionality is represented by Shape
members, and overridden members that appear in derived classes and have
behaviour as documented for Shape
, are not documented separately.
__init__
(self, canvas = None)¶Default class constructor.
canvas – an instance of Canvas
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.
line – the line an instance of LineShape
other – the other shape, an instance of Shape
attachFrom – the attachment from point ???
attachTo – the attachment to point ???
positionFrom – the from position
positionTo – the to position
Note
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.
theCanvas – an instance of Canvas
addAfter – if not None
, will add the shape after this shape
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.
pt1 – The first point of the line representing 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.
Note
This function expects the line to be either vertical or horizontal, and determines which.
ClearAttachments
(self)¶Clear internal custom attachment point shapes (of class
AttachmentPoint
)
ClearRegions
(self)¶Clear the ShapeRegions from the shape.
ClearText
(self, regionId = 0)¶Clear the text from the specified text region.
regionId – the region identifier
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)¶Is shape draggable?
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.
DrawLinks
(self, dc, attachment = -1, recurse = False)¶Draws any lines linked to this shape.
dc – the device context
attachment – ???
recurse – if True recurse through the children
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.
EraseLinks
(self, dc, attachment = -1, recurse = False)¶Erase links attached to this shape, but do not repair damage caused to other shapes.
dc – the device context
attachment – ???
recurse – if True recurse through the children
FindRegion
(self, name)¶Find the actual image (‘this’ if non-composite) and region id for the given region name.
name (str) – the 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.
dc – the device contexr
s (str) – the text string
i (int) – the region identifier
GetAttachmentLineCount
(self, attachment)¶Get the number of lines at this attachment position.
attachment – ???
the count of lines at this position
GetAttachmentMode
(self)¶Get the attachment mode.
GetAttachmentPosition
(self, attachment, nth = 0, no_arcs = 1, line = None)¶Get the position at which the given attachment point should be drawn.
attachment – the attachment ???
nth – get nth attachment ???
no_arcs – ???
line – ???
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.
attachment – the attachment ???
nth – get nth attachment ???
no_arcs – ???
line – ???
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.
attachment – ???
False if there are no lines at this attachment.
GetBranchingAttachmentPoint
(self, attachment, n)¶Get branching attachment point.
attachment – ???
n – ???
GetBranchingAttachmentRoot
(self, attachment)¶Get the root point at the given attachment.
attachment – ???
GetBranchStyle
(self)¶Get the branch style.
GetBrush
(self)¶Get 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)¶Get the list of children for this shape.
GetClassName
(self)¶GetDisableLabel
(self)¶True if the default region will not be shown, False otherwise.
GetDrawHandles
(self)¶Get the list of drawhandles.
GetEventHandler
(self)¶Get 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.
regionId – the region identifier
GetFormatMode
(self, regionId = 0)¶Get the format mode.
regionId – the region identifier, default=0
GetId
(self)¶Get the integer identifier for this shape.
GetLinePosition
(self, line)¶Get the zero-based position of line in the list of lines for this shape.
line – line to find position for
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)¶Get the number of text regions for this shape.
GetParent
(self)¶Get the parent of this shape, if it is part of a composite.
GetPen
(self)¶Get 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.
x1 – the x1 position
y1 – the y1 position
x2 – the x2 position
y2 – the y2 position
False if the line doesn’t hit the perimeter.
GetRegionId
(self, name)¶Get the region’s identifier by name.
name (str) – the regions name
Note
This is not unique for within an entire composite, but is unique for the image.
GetRegionName
(self, regionId = 0)¶Get the region’s name.
regionId – the region identifier
Note
A region’s name can be used to uniquely determine a region within
an entire composite image hierarchy. .. seealso:: SetRegionName
.
GetRegions
(self)¶Get the list of ShapeRegions.
GetRotation
(self)¶Return the angle of rotation in radians.
GetSensitivityFilter
(self)¶Get the sensitivity filter, a bitlist of values.
GetShadowMode
(self)¶Get the current shadow mode setting.
GetSpaceAttachments
(self)¶Get 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.
regionId – the region identifier
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)¶Is image a descendant of this composite.
image – the image, is this a shape???
True if it is a descendant
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.
x – the x position
y – the y position
InsertInCanvas
(self, theCanvas)¶Insert the shape at the front of the shape list of canvas.
theCanvas – an instance 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).
logicalAttachment – ???
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.
dc – the device context
x – the x position
y – the y position
display – if True redraw
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.
MoveLinks
(self, dc)¶Redraw all the lines attached to the shape.
NameRegions
(self, parentName="")¶Make unique names for all the regions in a shape or composite shape.
parentName (str) – a prefix for the region names
OnBeginDragLeft
(self, x, y, keys = 0, attachment = 0)¶The begin drag left handler.
OnBeginDragRight
(self, x, y, keys = 0, attachment = 0)¶The begin drag right handler.
OnChangeAttachment
(self, attachment, line, ordering)¶Change attachment handler.
OnDragLeft
(self, draw, x, y, keys = 0, attachment = 0)¶The drag left handler.
OnDragRight
(self, draw, x, y, keys = 0, attachment = 0)¶The drag right handler.
OnDraw
(self, dc)¶not implemented???
OnDrawBranches
(self, dc, erase = False)¶The draw branches handler.
OnDrawBranchesAttachment
(self, dc, attachment, erase = False)¶The draw branches attachment handler.
OnDrawContents
(self, dc)¶The draw contents handler.
OnDrawControlPoints
(self, dc)¶The draw control points handler.
OnDrawOutline
(self, dc, x, y, w, h)¶The draw outline handler.
OnEndDragLeft
(self, x, y, keys = 0, attachment = 0)¶The end drag left handler.
OnEndDragRight
(self, x, y, keys = 0, attachment = 0)¶The end drag right handler.
OnErase
(self, dc)¶The erase handler.
OnEraseContents
(self, dc)¶The erase contents handler.
OnEraseControlPoints
(self, dc)¶The erase control points handler.
OnHighlight
(self, dc)¶not implemented???
OnLeftClick
(self, x, y, keys = 0, attachment = 0)¶The left click handler.
OnMoveLinks
(self, dc)¶The move links handler.
OnMovePre
(self, dc, x, y, old_x, old_y, display = True)¶The pre move handler.
OnRightClick
(self, x, y, keys = 0, attachment = 0)¶The right click handler.
OnSize
(self, x, y)¶not implemented???
OnSizingBeginDragLeft
(self, pt, x, y, keys = 0, attachment = 0)¶The sizing begin drag left handler.
OnSizingDragLeft
(self, pt, draw, x, y, keys = 0, attachment = 0)¶The sizing drag left handler.
OnSizingEndDragLeft
(self, pt, x, y, keys = 0, attachment = 0)¶The sizing end drag left handler.
PhysicalToLogicalAttachment
(self, physicalAttachment)¶Rotate the standard attachment point from physical (0 is always North) to logical (0 -> 1 if rotated by 90 degrees)
physicalAttachment – ???
Recentre
(self, dc)¶Recentre (or other formatting) 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.
theCanvas – an instance of Canvas
RemoveLine
(self, line)¶Remove the given line from the shape’s list of attached lines.
line – an instance of LineShape
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.
x – the x position
y – the y position
theta – the theta
Select
(self, select, dc = None)¶Select or deselect the given shape, drawing or erasing control points (handles) as necessary.
select – True to select
dc – the device context
Selected
(self)¶True if the shape is currently selected.
SetAttachmentMode
(self, mode)¶Set the attachment mode.
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)¶Set the attachment size.
w – width
h – height
SetBrush
(self, the_brush)¶Set the brush for filling the shape’s shape.
SetCanvas
(self, theCanvas)¶Set the canvas, identical to Shape.Attach.
theCanvas – an instance of Canvas
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.
drag – if True make shape draggable
recursive – if True recurse through children
SetDrawHandles
(self, drawH)¶Set the drawHandles flag for this shape and all descendants.
drawH – if 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.
handler – an instance of ShapeEvtHandler
SetFixedSize
(self, x, y)¶Set the shape to be fixed size.
x – the width
y – the height
SetFont
(self, the_font, regionId = 0)¶Set the font for the specified text region.
the_font – an instance of wx.Font
???
regionId – the region identifier
SetFormatMode
(self, mode, regionId = 0)¶Set the format mode of the region.
mode – can be a bit list of the following
Format mode |
Description |
---|---|
|
No formatting |
|
Horizontal centring |
|
Vertical centring |
regionId – the region identifier, default=0
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)¶Set the parent
p – the parent
SetPen
(self, the_pen)¶Set the pen for drawing the shape’s outline.
SetRegionName
(self, name, regionId = 0)¶Set the name for this region.
name (str) – the name to set
regionId – the region identifier
Note
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)¶Set rotation
rotation (int) – 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:
Mouse operation |
Description |
---|---|
|
left clicked |
|
right clicked |
|
left drag |
|
right drag |
|
all of the above |
recursive – if True recurse through children
SetShadowMode
(self, mode, redraw = False)¶Set the shadow mode (whether a shadow is drawn or not).
mode – can be one of the following:
Shadow mode |
Description |
---|---|
|
No shadow (the default) |
|
Shadow on the left side |
|
Shadow on the right side |
SetSize
(self, x, y, recursive = True)¶Set the shape’s size.
x – the x position
y – the y position
recursive – not used
SetSpaceAttachments
(self, sp)¶Indicate whether lines should be spaced out evenly at the point they touch the node.
sp – if True space out evently, else they should join at a single point.
SetTextColour
(self, the_colour, regionId = 0)¶Set the colour for the specified text region.
the_colour (str) – a valid colour name,
see wx.ColourDatabase
regionId – the region identifier
SetX
(self, x)¶Set the x position of the shape.
x – the x position
SetY
(self, y)¶Set the y position of the shape.
y – the y position
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.