Types#

Point#

class mhi.pscad.types.Point(x: int, y: int)#

Point class that supports Euclidean distance calculation.

Examples

>>> Point(10, 20) + Point(5, 7)
Point(x=15, y=27)

It also works with tuple coordinates.

>>> p = Point(4, 6) - (2, 3)
>>> p.x, p.y
(2, 3)

Changed in version 2.9.6: Now support addition, substraction, and calculation of Euclidian distance between points.

distance(other: Tuple[int, int] | Point) float#

Measures the Euclidean distance to a given point.

Parameters:

other (Union[Tuple[int, int], Point]) – The point to which the Euclidean distance is measured.

Returns:

Euclidean Distance

Return type:

float

Examples

>>> p1 = Point(10, 10)
>>> p2 = Point(13, 14)
>>> p1.distance(p2)
5.0

Added in version 2.9.6.

property x: int#

x coordinate of point on canvas

property y: int#

y coordinate of point on canvas

Port#

class mhi.pscad.types.Port(x: int, y: int, name: str, dim: int, type: NodeType, electrical: Electrical, signal: Signal)#

A named Port (input, output, or electrical connection) for a Component

property x: int#

x coordinate of the port

property y: int#

y coordinate of the port

property location: Point#

x,y coordinate of the port

property name: str#

name of the port

property dim: int#

dimension of the port (0 = conforming)

property type: NodeType#

type of node (ELECTRICAL, INPUT, OUTPUT)

property electrical: Electrical#

type of electrical nodes (FIXED, REMOVABLE, SWITCHED, GROUND)

property signal: Signal#

type for data (non-electrical) nodes (LOGICAL, INTEGER, REAL, COMPLEX)

Any Point#

class mhi.pscad.types.AnyPoint#

Either a Point, a Port, or a Tuple[int, int]

Rect#

class mhi.pscad.types.Rect(left: int, top: int, right: int, bottom: int)#

A class to represent rectangles on the canvas that supports mid-point calculation.

Examples

>>> rect = Rect(10, 10, 20, 20)
>>> rect
Rect(left=10, top=10, right=20, bottom=20)
>>> rect.mid
Point(x=15, y=15)

Added in version 2.9.6.

classmethod from_mid(mid_point: Tuple[int, int] | Point, w: int, h: int) Rect#

Initializes a rectangle given mid-point, width and height. For even w and/or h, mid-point would not be exactly at the centre but closer to top left corner.

Examples

>>> mid = (10, 10)
>>> Rect.from_mid(mid, 6,4)
Rect(left=8, top=9, right=13, bottom=12)
property left: int#

Left bound

property top: int#

Top bound

property right: int#

Right bound

property bottom: int#

Bottom bound

property width: int#

Width of the rectangle

property height: int#

Height of the rectangle

property mid: Point#

Returns the mid-point of rectangle. For even w and/or h, mid-point would not be exactly at the centre but closer to top left corner.

Enums#

final class mhi.pscad.types.NodeType#

Node Input/Output/Electrical Type

UNKNOWN: 0

INPUT: 1

OUTPUT: 2

ELECTRICAL: 3

SHORT: 4

final class mhi.pscad.types.Electrical#

Electrical Node Types

FIXED: 0

REMOVABLE: 1

SWITCHED: 2

GROUND: 3

final class mhi.pscad.types.Signal#

Data Signal Types

ELECTRICAL: 0

LOGICAL: 1

INTEGER: 2

REAL: 3

COMPLEX: 4

UNKNOWN: 15

final class mhi.pscad.types.Align#

Text Alignment

LEFT: 0

CENTER: 1

RIGHT: 2

final class mhi.pscad.types.Side#

Annotation Side

NONE: 0

LEFT: 1

TOP: 2

RIGHT: 3

BOTTOM: 4

AUTO: 5

final class mhi.pscad.types.LineStyle#

Line Styles

SOLID: 0

DASH: 1

DOT: 2

DASHDOT: 3

final class mhi.pscad.types.FillStyle#

Fill Styles

HOLLOW: 0

SOLID: 1

BACKWARD_DIAGONAL: 2

FORWARD_DIAGONAL: 3

CROSS: 4

DIAGONAL_CROSS: 5

HORIZONTAL: 6

VERTICAL: 7

GRADIENT_HORZ: 8

GRADIENT_VERT: 9

GRADIENT_BACK_DIAG: 10

GRADIENT_FORE_DIAG: 11

GRADIENT_RADIAL: 12

final class mhi.pscad.types.ProjectType#

Project Types

CASE: 1

LIBRARY: 2

final class mhi.pscad.types.LookIn#

Look In - for search

MODULE: 0

PROJECT: 1

WORKSPACE: 2

WORKSPACE_NO_MASTER_LIBRARY: 3