Documentation/Source/eric5.Graphics.AssociationItem.html

Sun, 18 May 2014 14:13:09 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 18 May 2014 14:13:09 +0200
changeset 3591
2f2a4a76dd22
parent 3018
70924c0bdaf1
permissions
-rw-r--r--

Corrected a bunch of source docu issues.

<!DOCTYPE html>
<html><head>
<title>eric5.Graphics.AssociationItem</title>
<meta charset="UTF-8">
<style>
body {
    background: #EDECE6;
    margin: 0em 1em 10em 1em;
    color: black;
}

h1 { color: white; background: #85774A; }
h2 { color: white; background: #85774A; }
h3 { color: white; background: #9D936E; }
h4 { color: white; background: #9D936E; }
    
a { color: #BA6D36; }

</style>
</head>
<body><a NAME="top" ID="top"></a>
<h1>eric5.Graphics.AssociationItem</h1>
<p>
Module implementing a graphics item for an association between two items.
</p>
<h3>Global Attributes</h3>
<table>
<tr><td>Center</td></tr><tr><td>East</td></tr><tr><td>Generalisation</td></tr><tr><td>Imports</td></tr><tr><td>NoRegion</td></tr><tr><td>Normal</td></tr><tr><td>North</td></tr><tr><td>NorthEast</td></tr><tr><td>NorthWest</td></tr><tr><td>South</td></tr><tr><td>SouthEast</td></tr><tr><td>SouthWest</td></tr><tr><td>West</td></tr>
</table>
<h3>Classes</h3>
<table>
<tr>
<td><a href="#AssociationItem">AssociationItem</a></td>
<td>Class implementing a graphics item for an association between two items.</td>
</tr>
</table>
<h3>Functions</h3>
<table>
<tr><td>None</td></tr>
</table>
<hr /><hr />
<a NAME="AssociationItem" ID="AssociationItem"></a>
<h2>AssociationItem</h2>
<p>
    Class implementing a graphics item for an association between two items.
</p><p>
    The association is drawn as an arrow starting at the first items and
    ending at the second.
</p>
<h3>Derived from</h3>
E5ArrowItem
<h3>Class Attributes</h3>
<table>
<tr><td>None</td></tr>
</table>
<h3>Class Methods</h3>
<table>
<tr>
<td><a href="#AssociationItem.parseAssociationItemDataString">parseAssociationItemDataString</a></td>
<td>Class method to parse the given persistence data.</td>
</tr>
</table>
<h3>Methods</h3>
<table>
<tr>
<td><a href="#AssociationItem.__init__">AssociationItem</a></td>
<td>Constructor</td>
</tr><tr>
<td><a href="#AssociationItem.__calculateEndingPoints_center">__calculateEndingPoints_center</a></td>
<td>Private method to calculate the ending points of the association item.</td>
</tr><tr>
<td><a href="#AssociationItem.__calculateEndingPoints_rectangle">__calculateEndingPoints_rectangle</a></td>
<td>Private method to calculate the ending points of the association item.</td>
</tr><tr>
<td><a href="#AssociationItem.__calculateEndingPoints_topToBottom">__calculateEndingPoints_topToBottom</a></td>
<td>Private method to calculate the ending points of the association item.</td>
</tr><tr>
<td><a href="#AssociationItem.__findIntersection">__findIntersection</a></td>
<td>Private method to calculate the intersection point of two lines.</td>
</tr><tr>
<td><a href="#AssociationItem.__findPointRegion">__findPointRegion</a></td>
<td>Private method to find out, which region of rectangle rect contains the point (PosX, PosY) and returns the region number.</td>
</tr><tr>
<td><a href="#AssociationItem.__findRectIntersectionPoint">__findRectIntersectionPoint</a></td>
<td>Private method to find the intersetion point of a line with a rectangle.</td>
</tr><tr>
<td><a href="#AssociationItem.__mapRectFromItem">__mapRectFromItem</a></td>
<td>Private method to map item's rectangle to this item's coordinate system.</td>
</tr><tr>
<td><a href="#AssociationItem.__updateEndPoint">__updateEndPoint</a></td>
<td>Private method to update an endpoint.</td>
</tr><tr>
<td><a href="#AssociationItem.buildAssociationItemDataString">buildAssociationItemDataString</a></td>
<td>Public method to build a string to persist the specific item data.</td>
</tr><tr>
<td><a href="#AssociationItem.unassociate">unassociate</a></td>
<td>Public method to unassociate from the widgets.</td>
</tr><tr>
<td><a href="#AssociationItem.widgetMoved">widgetMoved</a></td>
<td>Public method to recalculate the association after a widget was moved.</td>
</tr>
</table>
<h3>Static Methods</h3>
<table>
<tr><td>None</td></tr>
</table>
<a NAME="AssociationItem.parseAssociationItemDataString" ID="AssociationItem.parseAssociationItemDataString"></a>
<h4>AssociationItem.parseAssociationItemDataString (class method)</h4>
<b>parseAssociationItemDataString</b>(<i>data</i>)
<p>
        Class method to parse the given persistence data.
</p><dl>
<dt><i>data</i></dt>
<dd>
persisted data to be parsed (string)
</dd>
</dl><dl>
<dt>Returns:</dt>
<dd>
tuple with the IDs of the source and destination items,
            the association type and a flag indicating to associate from top
            to bottom (integer, integer, integer, boolean)
</dd>
</dl><a NAME="AssociationItem.__init__" ID="AssociationItem.__init__"></a>
<h4>AssociationItem (Constructor)</h4>
<b>AssociationItem</b>(<i>itemA, itemB, type=Normal, topToBottom=False, parent=None</i>)
<p>
        Constructor
</p><dl>
<dt><i>itemA</i></dt>
<dd>
first widget of the association
</dd><dt><i>itemB</i></dt>
<dd>
second widget of the association
</dd><dt><i>type</i></dt>
<dd>
type of the association. This must be one of
            <ul>
            <li>Normal (default)</li>
            <li>Generalisation</li>
            <li>Imports</li>
            </ul>
</dd><dt><i>topToBottom=</i></dt>
<dd>
flag indicating to draw the association
            from item A top to item B bottom (boolean)
</dd><dt><i>parent=</i></dt>
<dd>
reference to the parent object (QGraphicsItem)
</dd>
</dl><a NAME="AssociationItem.__calculateEndingPoints_center" ID="AssociationItem.__calculateEndingPoints_center"></a>
<h4>AssociationItem.__calculateEndingPoints_center</h4>
<b>__calculateEndingPoints_center</b>(<i></i>)
<p>
        Private method to calculate the ending points of the association item.
</p><p>
        The ending points are calculated from the centers of the
        two associated items.
</p><a NAME="AssociationItem.__calculateEndingPoints_rectangle" ID="AssociationItem.__calculateEndingPoints_rectangle"></a>
<h4>AssociationItem.__calculateEndingPoints_rectangle</h4>
<b>__calculateEndingPoints_rectangle</b>(<i></i>)
<p>
        Private method to calculate the ending points of the association item.
</p><p>
        The ending points are calculated by the following method.
</p><p>
        For each item the diagram is divided in four Regions by its diagonals
        as indicated below
        <pre>
                   \  Region 2  /
                    \          /
                     |--------|
                     | \    / |
                     |  \  /  |
                     |   \/   |
            Region 1 |   /\   | Region 3
                     |  /  \  |
                     | /    \ |
                     |--------|
                    /          \
                   /  Region 4  \
        </pre>
</p><p>
        Each diagonal is defined by two corners of the bounding rectangle
</p><p>
        To calculate the start point  we have to find out in which
        region (defined by itemA's diagonals) is itemB's TopLeft corner
        (lets call it region M). After that the start point will be
        the middle point of rectangle's side contained in region M.
</p><p>
        To calculate the end point we repeat the above but in the opposite
        direction (from itemB to itemA)
</p><a NAME="AssociationItem.__calculateEndingPoints_topToBottom" ID="AssociationItem.__calculateEndingPoints_topToBottom"></a>
<h4>AssociationItem.__calculateEndingPoints_topToBottom</h4>
<b>__calculateEndingPoints_topToBottom</b>(<i></i>)
<p>
        Private method to calculate the ending points of the association item.
</p><p>
        The ending points are calculated from the top center of the lower item
        to the bottom center of the upper item.
</p><a NAME="AssociationItem.__findIntersection" ID="AssociationItem.__findIntersection"></a>
<h4>AssociationItem.__findIntersection</h4>
<b>__findIntersection</b>(<i>p1, p2, p3, p4</i>)
<p>
        Private method to calculate the intersection point of two lines.
</p><p>
        The first line is determined by the points p1 and p2, the second
        line by p3 and p4. If the intersection point is not contained in
        the segment p1p2, then it returns (-1.0, -1.0).
</p><p>
        For the function's internal calculations remember:<br />
        QT coordinates start with the point (0,0) as the topleft corner
        and x-values increase from left to right and y-values increase
        from top to bottom; it means the visible area is quadrant I in
        the regular XY coordinate system
</p><p>
        <pre>
            Quadrant II     |   Quadrant I
           -----------------|-----------------
            Quadrant III    |   Quadrant IV
        </pre>
</p><p>
        In order for the linear function calculations to work in this method
        we must switch x and y values (x values become y values and viceversa)
</p><dl>
<dt><i>p1</i></dt>
<dd>
first point of first line (QPointF)
</dd><dt><i>p2</i></dt>
<dd>
second point of first line (QPointF)
</dd><dt><i>p3</i></dt>
<dd>
first point of second line (QPointF)
</dd><dt><i>p4</i></dt>
<dd>
second point of second line (QPointF)
</dd>
</dl><dl>
<dt>Returns:</dt>
<dd>
the intersection point (QPointF)
</dd>
</dl><a NAME="AssociationItem.__findPointRegion" ID="AssociationItem.__findPointRegion"></a>
<h4>AssociationItem.__findPointRegion</h4>
<b>__findPointRegion</b>(<i>rect, posX, posY</i>)
<p>
        Private method to find out, which region of rectangle rect contains
        the point (PosX, PosY) and returns the region number.
</p><dl>
<dt><i>rect</i></dt>
<dd>
rectangle to calculate the region for (QRectF)
</dd><dt><i>posX</i></dt>
<dd>
x position of point (float)
</dd><dt><i>posY</i></dt>
<dd>
y position of point (float)
</dd>
</dl><dl>
<dt>Returns:</dt>
<dd>
the calculated region number<br />
            West = Region 1<br />
            North = Region 2<br />
            East = Region 3<br />
            South = Region 4<br />
            NorthWest = On diagonal 2 between Region 1 and 2<br />
            NorthEast = On diagonal 1 between Region 2 and 3<br />
            SouthEast = On diagonal 2 between Region 3 and 4<br />
            SouthWest = On diagonal 1 between Region4 and 1<br />
            Center = On diagonal 1 and On diagonal 2 (the center)<br />
</dd>
</dl><a NAME="AssociationItem.__findRectIntersectionPoint" ID="AssociationItem.__findRectIntersectionPoint"></a>
<h4>AssociationItem.__findRectIntersectionPoint</h4>
<b>__findRectIntersectionPoint</b>(<i>item, p1, p2</i>)
<p>
        Private method to find the intersetion point of a line with a
        rectangle.
</p><dl>
<dt><i>item</i></dt>
<dd>
item to check against
</dd><dt><i>p1</i></dt>
<dd>
first point of the line (QPointF)
</dd><dt><i>p2</i></dt>
<dd>
second point of the line (QPointF)
</dd>
</dl><dl>
<dt>Returns:</dt>
<dd>
the intersection point (QPointF)
</dd>
</dl><a NAME="AssociationItem.__mapRectFromItem" ID="AssociationItem.__mapRectFromItem"></a>
<h4>AssociationItem.__mapRectFromItem</h4>
<b>__mapRectFromItem</b>(<i>item</i>)
<p>
        Private method to map item's rectangle to this item's coordinate
        system.
</p><dl>
<dt><i>item</i></dt>
<dd>
reference to the item to be mapped (QGraphicsRectItem)
</dd>
</dl><dl>
<dt>Returns:</dt>
<dd>
item's rectangle in local coordinates (QRectF)
</dd>
</dl><a NAME="AssociationItem.__updateEndPoint" ID="AssociationItem.__updateEndPoint"></a>
<h4>AssociationItem.__updateEndPoint</h4>
<b>__updateEndPoint</b>(<i>region, isWidgetA</i>)
<p>
        Private method to update an endpoint.
</p><dl>
<dt><i>region</i></dt>
<dd>
the region for the endpoint (integer)
</dd><dt><i>isWidgetA</i></dt>
<dd>
flag indicating update for itemA is done (boolean)
</dd>
</dl><a NAME="AssociationItem.buildAssociationItemDataString" ID="AssociationItem.buildAssociationItemDataString"></a>
<h4>AssociationItem.buildAssociationItemDataString</h4>
<b>buildAssociationItemDataString</b>(<i></i>)
<p>
        Public method to build a string to persist the specific item data.
</p><p>
        This string should be built like "attribute=value" with pairs separated
        by ", ". value must not contain ", " or newlines.
</p><dl>
<dt>Returns:</dt>
<dd>
persistence data (string)
</dd>
</dl><a NAME="AssociationItem.unassociate" ID="AssociationItem.unassociate"></a>
<h4>AssociationItem.unassociate</h4>
<b>unassociate</b>(<i></i>)
<p>
        Public method to unassociate from the widgets.
</p><a NAME="AssociationItem.widgetMoved" ID="AssociationItem.widgetMoved"></a>
<h4>AssociationItem.widgetMoved</h4>
<b>widgetMoved</b>(<i></i>)
<p>
        Public method to recalculate the association after a widget was moved.
</p>
<div align="right"><a href="#top">Up</a></div>
<hr />
</body></html>

eric ide

mercurial