kigadgets.drawing ================= .. py:module:: kigadgets.drawing .. autoapi-nested-parse:: Drawing shape handling module for KiCad PCB objects. This module provides pythonic wrappers for KiCad's native drawing shapes. Each shape class (Segment, Circle, Arc, Rectangle, Polygon) - inherits from Drawing base class - wraps a pcbnew.Shape native object There are two ways to instantiate a Drawing: - Pre-existing SWIG objects are wrapped using a factory pattern for type detection - New Drawings can be instantiated directly using __init__ methods All objects support geohashing for geometric comparison and testing capabilities. Attributes ---------- .. autoapisummary:: kigadgets.drawing.Arc Classes ------- .. autoapisummary:: kigadgets.drawing.ShapeType kigadgets.drawing.Drawing kigadgets.drawing.Segment kigadgets.drawing.Circle kigadgets.drawing.Arc_v5 kigadgets.drawing.Arc_v6 kigadgets.drawing.Polygon kigadgets.drawing.Rectangle kigadgets.drawing.TextPCB Functions --------- .. autoapisummary:: kigadgets.drawing.wrap_drawing Module Contents --------------- .. py:class:: ShapeType .. py:attribute:: Segment .. py:attribute:: Circle .. py:attribute:: Arc .. py:attribute:: Polygon .. py:attribute:: Rect .. py:function:: wrap_drawing(instance: Any) -> Union[Segment, Circle, Arc, Rectangle, Polygon, TextPCB] Handles anything found in BOARD.GetDrawings Feeds through to shape wrap methods based on the type of shape. It also detects and feeds through text, which are handled separately from geometric shapes. .. py:class:: Drawing Bases: :py:obj:`kigadgets.item.HasLayer`, :py:obj:`kigadgets.item.HasPosition`, :py:obj:`kigadgets.item.HasWidth`, :py:obj:`kigadgets.item.Selectable`, :py:obj:`kigadgets.item.BoardItem` .. autoapi-inheritance-diagram:: kigadgets.drawing.Drawing :parts: 1 Base class of shape drawings, not including text .. py:property:: layer :type: str .. py:method:: geohash() -> int .. py:property:: position :type: kigadgets.Point .. py:property:: x :type: float .. py:property:: y :type: float .. py:property:: width :type: float .. py:property:: is_selected :type: bool .. py:method:: select(value: bool = True) -> None Selecting changes the appearance and also plays a role in determining what will be the subject of a subsequent command (delete, move to layer, etc.) .. py:method:: deselect() -> None .. py:method:: brighten(value: bool = True) -> None Brightening gives a bright green appearance .. py:property:: native_obj :type: Any .. py:property:: board :type: Optional[kigadgets.board.Board] .. py:method:: wrap(instance: Any) -> BoardItem :classmethod: .. py:class:: Segment(start: kigadgets.units.CoordinateLike, end: kigadgets.units.CoordinateLike, layer: str = 'F.SilkS', width: float = 0.15, board: Optional[Board] = None) Bases: :py:obj:`Drawing` .. autoapi-inheritance-diagram:: kigadgets.drawing.Segment :parts: 1 Base class of shape drawings, not including text .. py:property:: start :type: kigadgets.Point .. py:property:: end :type: kigadgets.Point .. py:attribute:: layer :value: 'F.SilkS' .. py:attribute:: width :value: 0.15 .. py:method:: geohash() -> int .. py:property:: position :type: kigadgets.Point .. py:property:: x :type: float .. py:property:: y :type: float .. py:property:: is_selected :type: bool .. py:method:: select(value: bool = True) -> None Selecting changes the appearance and also plays a role in determining what will be the subject of a subsequent command (delete, move to layer, etc.) .. py:method:: deselect() -> None .. py:method:: brighten(value: bool = True) -> None Brightening gives a bright green appearance .. py:property:: native_obj :type: Any .. py:property:: board :type: Optional[kigadgets.board.Board] .. py:method:: wrap(instance: Any) -> BoardItem :classmethod: .. py:class:: Circle(center: kigadgets.units.CoordinateLike, radius: float, layer: str = 'F.SilkS', width: float = 0.15, board: Optional[Board] = None) Bases: :py:obj:`Drawing` .. autoapi-inheritance-diagram:: kigadgets.drawing.Circle :parts: 1 Base class of shape drawings, not including text .. py:property:: center :type: kigadgets.Point .. py:attribute:: width :value: 0.15 .. py:attribute:: layer :value: 'F.SilkS' .. py:property:: start :type: kigadgets.Point .. py:property:: radius :type: float .. py:method:: geohash() -> int .. py:property:: position :type: kigadgets.Point .. py:property:: x :type: float .. py:property:: y :type: float .. py:property:: is_selected :type: bool .. py:method:: select(value: bool = True) -> None Selecting changes the appearance and also plays a role in determining what will be the subject of a subsequent command (delete, move to layer, etc.) .. py:method:: deselect() -> None .. py:method:: brighten(value: bool = True) -> None Brightening gives a bright green appearance .. py:property:: native_obj :type: Any .. py:property:: board :type: Optional[kigadgets.board.Board] .. py:method:: wrap(instance: Any) -> BoardItem :classmethod: .. py:class:: Arc_v5(center: kigadgets.units.CoordinateLike, radius: float, start_angle: float, stop_angle: float, layer: str = 'F.SilkS', width: float = 0.15, board: Optional[Board] = None) Bases: :py:obj:`Drawing` .. autoapi-inheritance-diagram:: kigadgets.drawing.Arc_v5 :parts: 1 Base class of shape drawings, not including text .. py:property:: center :type: kigadgets.Point .. py:property:: radius :type: float .. py:property:: start :type: kigadgets.Point .. py:property:: end :type: kigadgets.Point .. py:property:: angle :type: float .. py:method:: geohash() -> int .. py:property:: layer :type: str .. py:property:: position :type: kigadgets.Point .. py:property:: x :type: float .. py:property:: y :type: float .. py:property:: width :type: float .. py:property:: is_selected :type: bool .. py:method:: select(value: bool = True) -> None Selecting changes the appearance and also plays a role in determining what will be the subject of a subsequent command (delete, move to layer, etc.) .. py:method:: deselect() -> None .. py:method:: brighten(value: bool = True) -> None Brightening gives a bright green appearance .. py:property:: native_obj :type: Any .. py:property:: board :type: Optional[kigadgets.board.Board] .. py:method:: wrap(instance: Any) -> BoardItem :classmethod: .. py:class:: Arc_v6(center: kigadgets.units.CoordinateLike, radius: float, start_angle: float, stop_angle: float, layer: str = 'F.SilkS', width: float = 0.15, board: Optional[Board] = None) Bases: :py:obj:`Drawing` .. autoapi-inheritance-diagram:: kigadgets.drawing.Arc_v6 :parts: 1 Base class of shape drawings, not including text .. py:property:: center :type: kigadgets.Point .. py:property:: start :type: kigadgets.Point .. py:property:: angle :type: float .. py:attribute:: layer :value: 'F.SilkS' .. py:attribute:: width :value: 0.15 .. py:property:: radius :type: float .. py:property:: end :type: kigadgets.Point .. py:method:: geohash() -> int .. py:property:: position :type: kigadgets.Point .. py:property:: x :type: float .. py:property:: y :type: float .. py:property:: is_selected :type: bool .. py:method:: select(value: bool = True) -> None Selecting changes the appearance and also plays a role in determining what will be the subject of a subsequent command (delete, move to layer, etc.) .. py:method:: deselect() -> None .. py:method:: brighten(value: bool = True) -> None Brightening gives a bright green appearance .. py:property:: native_obj :type: Any .. py:property:: board :type: Optional[kigadgets.board.Board] .. py:method:: wrap(instance: Any) -> BoardItem :classmethod: .. py:data:: Arc .. py:class:: Polygon(coords: List[kigadgets.units.CoordinateLike], layer: str = 'F.SilkS', width: float = 0.15, board: Optional[Board] = None) Bases: :py:obj:`Drawing` .. autoapi-inheritance-diagram:: kigadgets.drawing.Polygon :parts: 1 Base class of shape drawings, not including text .. py:attribute:: layer :value: 'F.SilkS' .. py:attribute:: width :value: 0.15 .. py:property:: filled :type: bool .. py:method:: get_vertices() -> List[kigadgets.Point] .. py:method:: to_segments(replace: bool = False) -> List[Segment] If replace is true, removes the original polygon .. py:method:: fillet(radius_mm: float, tol_mm: float = 0.01) -> None .. py:method:: contains(point: kigadgets.units.CoordinateLike) -> bool Does this shape contain the point :param point: the point as a tuple or kigadgets.Point :type point: tuple, Point :returns: True if contained :rtype: bool .. py:method:: geohash() -> int .. py:property:: position :type: kigadgets.Point .. py:property:: x :type: float .. py:property:: y :type: float .. py:property:: is_selected :type: bool .. py:method:: select(value: bool = True) -> None Selecting changes the appearance and also plays a role in determining what will be the subject of a subsequent command (delete, move to layer, etc.) .. py:method:: deselect() -> None .. py:method:: brighten(value: bool = True) -> None Brightening gives a bright green appearance .. py:property:: native_obj :type: Any .. py:property:: board :type: Optional[kigadgets.board.Board] .. py:method:: wrap(instance: Any) -> BoardItem :classmethod: .. py:class:: Rectangle(corner_nw: kigadgets.units.CoordinateLike, corner_se: kigadgets.units.CoordinateLike, layer: str = 'F.SilkS', width: float = 0.15, board: Optional[Board] = None) Bases: :py:obj:`Polygon` .. autoapi-inheritance-diagram:: kigadgets.drawing.Rectangle :parts: 1 Inherits x,y get/set from HasPosition .. py:attribute:: layer :value: 'F.SilkS' .. py:attribute:: width :value: 0.15 .. py:method:: from_centersize(xcent: float, ycent: float, xsize: float, ysize: float, layer: str = 'F.SilkS', width: float = 0.15, board: Optional[Board] = None) -> Rectangle :classmethod: .. py:method:: get_vertices() -> List[kigadgets.Point] .. py:property:: size :type: Tuple[float, float] .. py:method:: to_polygon(replace: bool = False) -> Polygon .. py:method:: fillet(radius_mm: float, tol_mm: float = 0.01) -> None Deletes the rectangle but that is ok in most situations It can be undone IF it is run inside an action plugin .. py:method:: contains(point: kigadgets.units.CoordinateLike) -> bool Does this shape contain the point :param point: the point as a tuple or kigadgets.Point :type point: tuple, Point :returns: True if contained :rtype: bool .. py:property:: filled :type: bool .. py:method:: to_segments(replace: bool = False) -> List[Segment] If replace is true, removes the original polygon .. py:method:: geohash() -> int .. py:property:: position :type: kigadgets.Point .. py:property:: x :type: float .. py:property:: y :type: float .. py:property:: is_selected :type: bool .. py:method:: select(value: bool = True) -> None Selecting changes the appearance and also plays a role in determining what will be the subject of a subsequent command (delete, move to layer, etc.) .. py:method:: deselect() -> None .. py:method:: brighten(value: bool = True) -> None Brightening gives a bright green appearance .. py:property:: native_obj :type: Any .. py:property:: board :type: Optional[kigadgets.board.Board] .. py:method:: wrap(instance: Any) -> BoardItem :classmethod: .. py:class:: TextPCB(position: kigadgets.units.CoordinateLike, text: Optional[str] = None, layer: str = 'F.SilkS', size: float = 1.0, thickness: float = 0.15, justification: Optional[Union[str, Tuple[str, str]]] = None, mirrored: bool = False, board: Optional[Board] = None) Bases: :py:obj:`kigadgets.item.HasLayer`, :py:obj:`kigadgets.item.HasPosition`, :py:obj:`kigadgets.item.Selectable`, :py:obj:`kigadgets.item.BoardItem`, :py:obj:`kigadgets.item.TextEsque` .. autoapi-inheritance-diagram:: kigadgets.drawing.TextPCB :parts: 1 Mixin for layer handling based on *strings* (like `'F.Cu'`, `'B.Silkscreen'`, `'User.12'`, etc.). If the layer is not present, it will be caught at runtime, rather than disallowed. .. py:attribute:: position .. py:attribute:: layer :value: 'F.SilkS' .. py:attribute:: size :value: 1.0 .. py:attribute:: thickness :value: 0.15 .. py:attribute:: mirrored :value: False .. py:method:: geohash() -> int .. py:property:: x :type: float .. py:property:: y :type: float .. py:property:: is_selected :type: bool .. py:method:: select(value: bool = True) -> None Selecting changes the appearance and also plays a role in determining what will be the subject of a subsequent command (delete, move to layer, etc.) .. py:method:: deselect() -> None .. py:method:: brighten(value: bool = True) -> None Brightening gives a bright green appearance .. py:property:: native_obj :type: Any .. py:property:: board :type: Optional[kigadgets.board.Board] .. py:method:: wrap(instance: Any) -> BoardItem :classmethod: .. py:attribute:: justification_lookups .. py:property:: text :type: str .. py:property:: orientation :type: float Rotation of the item in degrees. .. py:property:: justification :type: Tuple[str, str]