.. wxPython Phoenix documentation

   This file was generated by Phoenix's sphinx generator and associated
   tools, do not edit by hand.

   Copyright: (c) 2011-2020 by Total Control Software
   License:   wxWindows License

.. include:: headings.inc

.. currentmodule:: wx.lib.ogl.lines

.. highlight:: python



.. _wx.lib.ogl.lines.LineShape:

==========================================================================================================================================
|phoenix_title|  **wx.lib.ogl.lines.LineShape**
==========================================================================================================================================

The LineShape class may be attached to two nodes, it may be segmented,
in which case a control point is drawn for each joint.

A :class:`LineShape` may have arrows at the beginning, end and centre.



|

|class_hierarchy| Class Hierarchy
=================================

.. raw:: html

   <div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
   <img id="toggleBlock-trigger" src="_static/images/closed.png"/>
   Inheritance diagram for class <strong>LineShape</strong>:
   </div>
   <div id="toggleBlock-summary" style="display:block;"></div>
   <div id="toggleBlock-content" style="display:none;">
   <p class="graphviz">
   <center><img src="_static/images/inheritance/wx.lib.ogl.lines.LineShape_inheritance.png" alt="Inheritance diagram of LineShape" usemap="#dummy" class="inheritance"/></center>
   <script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
   <map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.lib.ogl.lines.LineShape.html" title="wx.lib.ogl.lines.LineShape" alt="" coords="29,160,220,189"/> <area shape="rect" id="node2" href="wx.lib.ogl.basic.Shape.html" title="wx.lib.ogl.basic.Shape" alt="" coords="41,83,208,112"/> <area shape="rect" id="node3" href="wx.lib.ogl.basic.ShapeEvtHandler.html" title="wx.lib.ogl.basic.ShapeEvtHandler" alt="" coords="5,5,244,35"/> </map> 
   </p>
   </div>

|


|super_classes| Known Superclasses
==================================

:class:`wx.lib.ogl.basic.Shape`

|


|method_summary| Methods Summary
================================

================================================================================ ================================================================================
:meth:`~wx.lib.ogl.lines.LineShape.__init__`                                     Default class constructor.
:meth:`~wx.lib.ogl.lines.LineShape.AddArrow`                                     Add an arrow (or annotation) to the line.
:meth:`~wx.lib.ogl.lines.LineShape.AddArrowOrdered`                              Add an arrowhead in the position indicated by the reference list
:meth:`~wx.lib.ogl.lines.LineShape.ClearArrow`                                   Delete the arrow with the given name.
:meth:`~wx.lib.ogl.lines.LineShape.ClearArrowsAtPosition`                        Delete the arrows at the specified position, or at any position if position is -1.
:meth:`~wx.lib.ogl.lines.LineShape.Delete`                                       Delete the line, unlink it first.
:meth:`~wx.lib.ogl.lines.LineShape.DeleteArrowHead`                              Delete arrowhead by position and name.
:meth:`~wx.lib.ogl.lines.LineShape.DeleteArrowHeadId`                            Delete arrowhead by id.
:meth:`~wx.lib.ogl.lines.LineShape.DeleteLineControlPoint`                       Delete an arbitary point on the line.
:meth:`~wx.lib.ogl.lines.LineShape.Draggable`                                    Line is not draggable.
:meth:`~wx.lib.ogl.lines.LineShape.DrawArrow`                                    Draw the given arrowhead (or annotation).
:meth:`~wx.lib.ogl.lines.LineShape.DrawArrows`                                   Draw all arrows.
:meth:`~wx.lib.ogl.lines.LineShape.DrawRegion`                                   Format one region at this position.
:meth:`~wx.lib.ogl.lines.LineShape.EraseRegion`                                  Erase one region at this position.
:meth:`~wx.lib.ogl.lines.LineShape.FindArrowHead`                                Find arrowhead by position and name.
:meth:`~wx.lib.ogl.lines.LineShape.FindArrowHeadId`                              Find arrowhead by id.
:meth:`~wx.lib.ogl.lines.LineShape.FindLineEndPoints`                            Finds the x, y points at the two ends of the line.
:meth:`~wx.lib.ogl.lines.LineShape.FindLinePosition`                             Find which position we're talking about.
:meth:`~wx.lib.ogl.lines.LineShape.FindMinimumWidth`                             Find the horizontal width for drawing a line with arrows in
:meth:`~wx.lib.ogl.lines.LineShape.FindNth`                                      Find the position of the line on the given object.
:meth:`~wx.lib.ogl.lines.LineShape.FormatText`                                   Format a text string according to the region size, adding
:meth:`~wx.lib.ogl.lines.LineShape.GetAlignmentEnd`                              Get alignment end.
:meth:`~wx.lib.ogl.lines.LineShape.GetAlignmentOrientation`                      Get the alignment orientation.
:meth:`~wx.lib.ogl.lines.LineShape.GetAlignmentStart`                            Get alignment start
:meth:`~wx.lib.ogl.lines.LineShape.GetAlignmentType`                             Get the alignment type.
:meth:`~wx.lib.ogl.lines.LineShape.GetArrows`                                    Get the defined arrows.
:meth:`~wx.lib.ogl.lines.LineShape.GetAttachmentFrom`                            Get the attachment point on the 'from' node.
:meth:`~wx.lib.ogl.lines.LineShape.GetAttachmentTo`                              Get the attachment point on the 'to' node.
:meth:`~wx.lib.ogl.lines.LineShape.GetBoundingBoxMin`                            Get the minimum bounding box.
:meth:`~wx.lib.ogl.lines.LineShape.GetEnds`                                      Get the visible endpoints of the lines for drawing between two objects.
:meth:`~wx.lib.ogl.lines.LineShape.GetFrom`                                      Get the 'from' object.
:meth:`~wx.lib.ogl.lines.LineShape.GetLabelPosition`                             Get the reference point for a label.
:meth:`~wx.lib.ogl.lines.LineShape.GetLineControlPoints`                         Get the line control points.
:meth:`~wx.lib.ogl.lines.LineShape.GetNextControlPoint`                          Find the next control point in the line after the start / end point,
:meth:`~wx.lib.ogl.lines.LineShape.GetTo`                                        Get the 'to' object.
:meth:`~wx.lib.ogl.lines.LineShape.HitTest`                                      Line hit test.
:meth:`~wx.lib.ogl.lines.LineShape.Initialise`                                   Initialise the line object.
:meth:`~wx.lib.ogl.lines.LineShape.InsertLineControlPoint`                       Insert a control point at an optional given position.
:meth:`~wx.lib.ogl.lines.LineShape.IsEnd`                                        `True` if shape is at the end of the line.
:meth:`~wx.lib.ogl.lines.LineShape.IsSpline`                                     If `True` a spline is drawn through the control points.
:meth:`~wx.lib.ogl.lines.LineShape.MakeControlPoints`                            Make handle control points.
:meth:`~wx.lib.ogl.lines.LineShape.MakeLineControlPoints`                        Make a given number of control points.
:meth:`~wx.lib.ogl.lines.LineShape.OnBeginDragLeft`                              not implemented???
:meth:`~wx.lib.ogl.lines.LineShape.OnCreateLabelShape`                           Create label shape handler.
:meth:`~wx.lib.ogl.lines.LineShape.OnDragLeft`                                   not implemented???
:meth:`~wx.lib.ogl.lines.LineShape.OnDraw`                                       The draw handler.
:meth:`~wx.lib.ogl.lines.LineShape.OnDrawContents`                               The draw contents handler.
:meth:`~wx.lib.ogl.lines.LineShape.OnDrawControlPoints`                          The draw control points handler.
:meth:`~wx.lib.ogl.lines.LineShape.OnDrawOutline`                                The draw outline handler.
:meth:`~wx.lib.ogl.lines.LineShape.OnEndDragLeft`                                not implemented???
:meth:`~wx.lib.ogl.lines.LineShape.OnErase`                                      The erase handler.
:meth:`~wx.lib.ogl.lines.LineShape.OnEraseControlPoints`                         The erase control points handler.
:meth:`~wx.lib.ogl.lines.LineShape.OnLabelMovePre`                               Label move 'pre' handler. ???
:meth:`~wx.lib.ogl.lines.LineShape.OnMoveLink`                                   The move linke handler, called when a connected object has moved, to move the link to
:meth:`~wx.lib.ogl.lines.LineShape.OnMoveMiddleControlPoint`                     The move middle control point handler.
:meth:`~wx.lib.ogl.lines.LineShape.OnMovePre`                                    The move 'pre' handler. ???
:meth:`~wx.lib.ogl.lines.LineShape.OnSizingBeginDragLeft`                        The sizing begin drag left handler.
:meth:`~wx.lib.ogl.lines.LineShape.OnSizingDragLeft`                             The sizing drag left handler.
:meth:`~wx.lib.ogl.lines.LineShape.OnSizingEndDragLeft`                          The sizing end drag left handler.
:meth:`~wx.lib.ogl.lines.LineShape.ResetControlPoints`                           Reset the control points.
:meth:`~wx.lib.ogl.lines.LineShape.Select`                                       Overridden select, to create / delete temporary label-moving objects.
:meth:`~wx.lib.ogl.lines.LineShape.SetAlignmentOrientation`                      Set the alignment orientation.
:meth:`~wx.lib.ogl.lines.LineShape.SetAlignmentType`                             Set the alignment type.
:meth:`~wx.lib.ogl.lines.LineShape.SetAttachmentFrom`                            Set the 'from' shape attachment.
:meth:`~wx.lib.ogl.lines.LineShape.SetAttachments`                               Specify which object attachment points should be used at each end of the line.
:meth:`~wx.lib.ogl.lines.LineShape.SetAttachmentTo`                              Set the 'to' shape attachment.
:meth:`~wx.lib.ogl.lines.LineShape.SetEnds`                                      Set the end positions of the line.
:meth:`~wx.lib.ogl.lines.LineShape.SetFrom`                                      Set the 'from' object for the line.
:meth:`~wx.lib.ogl.lines.LineShape.SetIgnoreOffsets`                             Set whether to ignore offsets from the end of the line when drawing.
:meth:`~wx.lib.ogl.lines.LineShape.SetSpline`                                    Specifies whether a spline is to be drawn through the control points.
:meth:`~wx.lib.ogl.lines.LineShape.SetTo`                                        Set the 'to' object for the line.
:meth:`~wx.lib.ogl.lines.LineShape.Straighten`                                   Straighten verticals and horizontals.
:meth:`~wx.lib.ogl.lines.LineShape.Unlink`                                       Unlink the line from the nodes at either end.
================================================================================ ================================================================================


|


|api| Class API
===============


.. class:: LineShape(Shape)

   The LineShape class may be attached to two nodes, it may be segmented,
   in which case a control point is drawn for each joint.
   
   A :class:`LineShape` may have arrows at the beginning, end and centre.

   .. method:: __init__(self)

      Default class constructor.


   .. method:: AddArrow(self, type, end = ARROW_POSITION_END, size = 10.0, xOffset = 0.0, name = "", mf = None, arrowId = -1)

      Add an arrow (or annotation) to the line.
      
      :param `type`: an arrow head type, one of the following
      
       ======================================== ==================================
       Arrow head type                          Description
       ======================================== ==================================
       `ARROW_HOLLOW_CIRCLE`                    a hollow circle
       `ARROW_FILLED_CIRCLE`                    a filled circle
       `ARROW_ARROW`                            an arrow
       `ARROW_SINGLE_OBLIQUE`                   a single oblique
       `ARROW_DOUBLE_OBLIQUE`                   a double oblique
       `ARROW_METAFILE`                         custom, define in metafile
       ======================================== ==================================
      
      :param `end`: may be one of the following
      
       ======================================== ==================================
       Arrow head type                          Description
       ======================================== ==================================
       `ARROW_POSITION_END`                     arrow appears at the end
       `ARROW_POSITION_START`                   arrow appears at the start
       ======================================== ==================================
      
      :param `size`: specifies the lenght of the arrow
      :param `xOffset`: specifies the offset from the end of the line
      :param `name`: specifies a name
      :param `mf`: mf can be a wxPseduoMetaFile, perhaps loaded from a simple Windows
        metafile.
      :param `arrowId`: the id for the arrow


   .. method:: AddArrowOrdered(self, arrow, referenceList, end)

      Add an arrowhead in the position indicated by the reference list
      of arrowheads, which contains all legal arrowheads for this line, in
      the correct order. E.g.
      
      Reference list:      a b c d e
      Current line list:   a d
      
      Add c, then line list is: a c d.
      
      If no legal arrowhead position, return FALSE. Assume reference list
      is for one end only, since it potentially defines the ordering for
      any one of the 3 positions. So we don't check the reference list for
      arrowhead position.
      
      :param `arrow`: an instance of :class:`ArrowHead`
      :param `referenceList`: ???
      :param `end`: ???


   .. method:: ClearArrow(self, name)

      Delete the arrow with the given name.
      
      :param `name`: name of arrow to delete


   .. method:: ClearArrowsAtPosition(self, end)

      Delete the arrows at the specified position, or at any position if position is -1.
      
      :param `end`: position to clear arrow from


   .. method:: Delete(self)

      Delete the line, unlink it first.


   .. method:: DeleteArrowHead(self, position, name)

      Delete arrowhead by position and name.
      
      if position is -1, matches any position.
      
      :param `position`: position of arrow to delete or -1
      :param `name`: name of arrow to delete


   .. method:: DeleteArrowHeadId(self, arrowId)

      Delete arrowhead by id.
      
      :param `arrowId`: id of arrow to delete


   .. method:: DeleteLineControlPoint(self)

      Delete an arbitary point on the line.


   .. method:: Draggable(self)

      Line is not draggable.
      
      :note: This is really to distinguish between lines and other images.
       For lines we want to pass drag to canvas, since lines tend to prevent
       dragging on a canvas (they get in the way.)


   .. method:: DrawArrow(self, dc, arrow, XOffset, proportionalOffset)

      Draw the given arrowhead (or annotation).
      
      :param `dc`: an instance of :class:`wx.MemoryDC`
      :param `arrow`: an instannce of :class:`ArrowHead`
      :param `XOffset`: the x offset ???
      :param `proportionalOffset`: ???


   .. method:: DrawArrows(self, dc)

      Draw all arrows.


   .. method:: DrawRegion(self, dc, region, x, y)

      Format one region at this position.
      
      :param `dc`: an instance of :class:`wx.MemoryDC`
      :param `dc`: an instance of :class:`~lib.ogl.ShapeRegion`
      :param `x`: the x position
      :param `y`: the y position


   .. method:: EraseRegion(self, dc, region, x, y)

      Erase one region at this position.
      
      :param `dc`: an instance of :class:`wx.MemoryDC`
      :param `dc`: an instance of :class:`~lib.ogl.ShapeRegion`
      :param `x`: the x position
      :param `y`: the y position


   .. method:: FindArrowHead(self, position, name)

      Find arrowhead by position and name.
      
      if position is -1, matches any position.
      
      :param `position`: position of arrow to find or -1
      :param `name`: name of arrow to find


   .. method:: FindArrowHeadId(self, arrowId)

      Find arrowhead by id.
      
      :param `arrowId`: id of arrow to find


   .. method:: FindLineEndPoints(self)

      Finds the x, y points at the two ends of the line.
      
      This function can be used by e.g. line-routing routines to
      get the actual points on the two node images where the lines will be
      drawn to / from.


   .. method:: FindLinePosition(self, x, y)

      Find which position we're talking about.
      
      :param `x`: x position
      :param `y`: y position
      
      :returns: ARROW_POSITION_START or ARROW_POSITION_MIDDLE or ARROW_POSITION_END.


   .. method:: FindMinimumWidth(self)

      Find the horizontal width for drawing a line with arrows in
      minimum space. Assume arrows at end only.


   .. method:: FindNth(self, image, incoming)

      Find the position of the line on the given object.
      
      Specify whether incoming or outgoing lines are being considered
      with incoming.
      
      :param `image`: a node image
      :param `incoming`: ``True`` to get incoming lines ???
      
      :returns: nth line, number of lines ???


   .. method:: FormatText(self, dc, s, i)

      Format a text string according to the region size, adding
      strings with positions to region text list.
      
      :param `dc`: an instance of :class:`wx.MemoryDC`
      :param str `s`: the text string
      :param int `i`: index to the region to be used???


   .. method:: GetAlignmentEnd(self)

      Get alignment end.


   .. method:: GetAlignmentOrientation(self, isEnd)

      Get the alignment orientation.
      
      :param `isEnd`: if ``True`` get the type for the begin, else for the end ???


   .. method:: GetAlignmentStart(self)

      Get alignment start


   .. method:: GetAlignmentType(self, isEnd)

      Get the alignment type.
      
      :param `isEnd`: if ``True`` get the type for the begin, else for the end ???


   .. method:: GetArrows(self)

      Get the defined arrows.


   .. method:: GetAttachmentFrom(self)

      Get the attachment point on the 'from' node.


   .. method:: GetAttachmentTo(self)

      Get the attachment point on the 'to' node.


   .. method:: GetBoundingBoxMin(self)

      Get the minimum bounding box.


   .. method:: GetEnds(self)

      Get the visible endpoints of the lines for drawing between two objects.


   .. method:: GetFrom(self)

      Get the 'from' object.


   .. method:: GetLabelPosition(self, position)

      Get the reference point for a label.
      
      :param `position`: 0 = middle, 1 = start, 2 = end, Region x and y are offsets from this.


   .. method:: GetLineControlPoints(self)

      Get the line control points.


   .. method:: GetNextControlPoint(self, shape)

      Find the next control point in the line after the start / end point,
      depending on whether the shape is at the start or end.
      
      :param `shape`: an instance of :class:`~lib.ogl.Shape` ???


   .. method:: GetTo(self)

      Get the 'to' object.


   .. method:: HitTest(self, x, y)

      Line hit test.
      
      :param `x`: x position
      :param `y`: y position


   .. method:: Initialise(self)

      Initialise the line object.


   .. method:: InsertLineControlPoint(self, dc = None, point = None)

      Insert a control point at an optional given position.
      
      :param `dc`: an instance of :class:`wx.MemoryDC`
      :param `point`: an optional point, otherwise will use _lineControlPoints


   .. method:: IsEnd(self, nodeObject)

      `True` if shape is at the end of the line.


   .. method:: IsSpline(self)

      If `True` a spline is drawn through the control points.


   .. method:: MakeControlPoints(self)

      Make handle control points.


   .. method:: MakeLineControlPoints(self, n)

      Make a given number of control points.
      
      :param int `n`: number of control points, minimum of two


   .. method:: OnBeginDragLeft(self, x, y, keys = 0, attachment = 0)

      not implemented???


   .. method:: OnCreateLabelShape(self, parent, region, w, h)

      Create label shape handler.


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

      not implemented???


   .. method:: OnDraw(self, dc)

      The draw handler.


   .. method:: OnDrawContents(self, dc)

      The draw contents handler.


   .. method:: OnDrawControlPoints(self, dc)

      The draw control points handler.


   .. method:: OnDrawOutline(self, dc, x, y, w, h)

      The draw outline handler.


   .. method:: OnEndDragLeft(self, x, y, keys = 0, attachment = 0)

      not implemented???


   .. method:: OnErase(self, dc)

      The erase handler.


   .. method:: OnEraseControlPoints(self, dc)

      The erase control points handler.


   .. method:: OnLabelMovePre(self, dc, labelShape, x, y, old_x, old_y, display)

      Label move 'pre' handler. ???


   .. method:: OnMoveLink(self, dc, moveControlPoints = True)

      The move linke handler, called when a connected object has moved, to move the link to
      correct position.


   .. method:: OnMoveMiddleControlPoint(self, dc, lpt, pt)

      The move middle control point handler.


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

      The move 'pre' handler. ???


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

      The sizing begin drag left handler.


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

      The sizing drag left handler.


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

      The sizing end drag left handler.


   .. method:: ResetControlPoints(self)

      Reset the control points.


   .. method:: Select(self, select, dc = None)

      Overridden select, to create / delete temporary label-moving objects.


   .. method:: SetAlignmentOrientation(self, isEnd, isHoriz)

      Set the alignment orientation.
      
      :param `isEnd`: ``True`` or ``False`` ???
      :param `isHoriz`: ``True`` of ``False`` ???


   .. method:: SetAlignmentType(self, isEnd, alignType)

      Set the alignment type.
      
      :param `isEnd`: if ``True`` set the type for the begin, else for the end ???
      :param `alignType`: one of the following
      
       ======================================== ==================================
       Arrow head type                          Description
       ======================================== ==================================
       `LINE_ALIGNMENT_HORIZ`                   Align horizontally
       `LINE_ALIGNMENT_VERT`                    Align vertically
       `LINE_ALIGNMENT_TO_NEXT_HANDLE`          Align to next handle
       `LINE_ALIGNMENT_NONE`                    vertical by default
       ======================================== ==================================


   .. method:: SetAttachmentFrom(self, attach)

      Set the 'from' shape attachment.


   .. method:: SetAttachments(self, from_attach, to_attach)

      Specify which object attachment points should be used at each end of the line.
      
      :param `from_attach`: the from points ???
      :param `to_attach`: the to points ???


   .. method:: SetAttachmentTo(self, attach)

      Set the 'to' shape attachment.


   .. method:: SetEnds(self, x1, y1, x2, y2)

      Set the end positions of the line.
      
      :param: `x1`: x1 position
      :param: `y1`: y1 position
      :param: `x2`: x2 position
      :param: `y2`: y2 position


   .. method:: SetFrom(self, object)

      Set the 'from' object for the line.


   .. method:: SetIgnoreOffsets(self, ignore)

      Set whether to ignore offsets from the end of the line when drawing.


   .. method:: SetSpline(self, spline)

      Specifies whether a spline is to be drawn through the control points.
      
      :param boolean `spline`: ``True`` draw a spline through control points.


   .. method:: SetTo(self, object)

      Set the 'to' object for the line.


   .. method:: Straighten(self, dc = None)

      Straighten verticals and horizontals.
      
      :param `dc`: an instance of :class:`wx.MemoryDC` or None


   .. method:: Unlink(self)

      Unlink the line from the nodes at either end.


