Skip to content

state_enums

state_enums

All state-defining enumerations.

_to_region_variant_map module-attribute

_to_region_variant_map = {
    Polarity.Clear: Polarity.ClearRegion,
    Polarity.Dark: Polarity.DarkRegion,
}

_polarity_invert_map module-attribute

_polarity_invert_map = {
    Polarity.Clear: Polarity.Dark,
    Polarity.Dark: Polarity.Clear,
    Polarity.ClearRegion: Polarity.DarkRegion,
    Polarity.DarkRegion: Polarity.ClearRegion,
    Polarity.DEBUG: Polarity.DEBUG2,
    Polarity.DEBUG2: Polarity.DEBUG,
}

_2d_rasterized_color_map module-attribute

_2d_rasterized_color_map = {
    "RESERVED_BLACK": 0,
    "RESERVED_WHITE": 255,
    Polarity.Dark: 240,
    Polarity.Clear: 15,
    Polarity.DarkRegion: 230,
    Polarity.ClearRegion: 30,
    Polarity.Background: 0,
    Polarity.DEBUG: 127,
    Polarity.DEBUG2: 75,
}

EnumFormatValue

Bases: Enum

Enum subclass which when stringified shows its value.

Source code in src/pygerber/gerberx3/state_enums.py
class EnumFormatValue(Enum):
    """Enum subclass which when stringified shows its value."""

    def __str__(self) -> str:
        return str(self.value)

DrawMode

Bases: EnumFormatValue

Drawing mode.

Source code in src/pygerber/gerberx3/state_enums.py
class DrawMode(EnumFormatValue):
    """Drawing mode."""

    Linear = "G01"
    """In linear plot mode a D01 operation generates a linear segment, from the current
    point to the (X, Y) coordinates in the command. The current point is then set to the
    (X, Y) coordinates.Outside a region statement the segment is stroked with the
    current aperture to create a draw graphical object. In a region statement the
    segment is added to the contour under construction."""

    ClockwiseCircular = "G02"
    """In circular plot mode a D01 operation generates an arc segment, from the current
    point to the (X, Y) coordinates in the command. The current point is then set to the
    (X, Y) coordinates. Outside a region statement the segment is stroked with the
    current aperture to create an arc graphical object. In a region statement the
    segment is added to the contour under construction. For compatibility with older
    versions of the Gerber format, a G75* must be issued before the first D01 in
    circular mode."""

    CounterclockwiseCircular = "G03"
    """In circular plot mode a D01 operation generates an arc segment, from the current
    point to the (X, Y) coordinates in the command. The current point is then set to the
    (X, Y) coordinates. Outside a region statement the segment is stroked with the
    current aperture to create an arc graphical object. In a region statement the
    segment is added to the contour under construction. For compatibility with older
    versions of the Gerber format, a G75* must be issued before the first D01 in
    circular mode."""

Linear class-attribute instance-attribute

Linear = 'G01'

In linear plot mode a D01 operation generates a linear segment, from the current point to the (X, Y) coordinates in the command. The current point is then set to the (X, Y) coordinates.Outside a region statement the segment is stroked with the current aperture to create a draw graphical object. In a region statement the segment is added to the contour under construction.

ClockwiseCircular class-attribute instance-attribute

ClockwiseCircular = 'G02'

In circular plot mode a D01 operation generates an arc segment, from the current point to the (X, Y) coordinates in the command. The current point is then set to the (X, Y) coordinates. Outside a region statement the segment is stroked with the current aperture to create an arc graphical object. In a region statement the segment is added to the contour under construction. For compatibility with older versions of the Gerber format, a G75* must be issued before the first D01 in circular mode.

CounterclockwiseCircular class-attribute instance-attribute

CounterclockwiseCircular = 'G03'

In circular plot mode a D01 operation generates an arc segment, from the current point to the (X, Y) coordinates in the command. The current point is then set to the (X, Y) coordinates. Outside a region statement the segment is stroked with the current aperture to create an arc graphical object. In a region statement the segment is added to the contour under construction. For compatibility with older versions of the Gerber format, a G75* must be issued before the first D01 in circular mode.

Polarity

Bases: EnumFormatValue

Aperture polarity.

Source code in src/pygerber/gerberx3/state_enums.py
class Polarity(EnumFormatValue):
    """Aperture polarity."""

    Clear = "C"
    Dark = "D"
    ClearRegion = "ClearRegion"
    DarkRegion = "DarkRegion"
    Background = "Background"
    DEBUG = "DBG"
    DEBUG2 = "DBG2"

    def invert(self) -> Polarity:
        """Return opposite polarity."""
        return _polarity_invert_map[self]

    def to_region_variant(self) -> Polarity:
        """Return region variant of polarity."""
        return _to_region_variant_map[self]

    def get_2d_rasterized_color(self) -> int:
        """Get color for "1" mode image."""
        return _2d_rasterized_color_map[self]

invert

invert() -> Polarity

Return opposite polarity.

Source code in src/pygerber/gerberx3/state_enums.py
def invert(self) -> Polarity:
    """Return opposite polarity."""
    return _polarity_invert_map[self]

to_region_variant

to_region_variant() -> Polarity

Return region variant of polarity.

Source code in src/pygerber/gerberx3/state_enums.py
def to_region_variant(self) -> Polarity:
    """Return region variant of polarity."""
    return _to_region_variant_map[self]

get_2d_rasterized_color

get_2d_rasterized_color() -> int

Get color for "1" mode image.

Source code in src/pygerber/gerberx3/state_enums.py
def get_2d_rasterized_color(self) -> int:
    """Get color for "1" mode image."""
    return _2d_rasterized_color_map[self]

Mirroring

Bases: EnumFormatValue

Aperture mirroring.

Source code in src/pygerber/gerberx3/state_enums.py
class Mirroring(EnumFormatValue):
    """Aperture mirroring."""

    NoMirroring = "N"
    XY = "XY"
    X = "X"
    Y = "Y"

Unit

Bases: EnumFormatValue

Aperture unit.

Source code in src/pygerber/gerberx3/state_enums.py
class Unit(EnumFormatValue):
    """Aperture unit."""

    Millimeters = "MM"
    Inches = "IN"

ImagePolarityEnum

Bases: EnumFormatValue

Image polarity.

Image Polarity (IP)

Note: The IP command is deprecated.

The IP command is responsible for setting the polarity for the entire image. It is designed to be used only once, preferably at the very beginning of the file.

7.1.3.1 Positive Image Polarity

Under the positive image polarity: - The image is generated in accordance with the specifications provided elsewhere in this document. - It's worth noting that, by default, image generation has always assumed a positive image polarity.

7.1.3.2 Negative Image Polarity

When the negative image polarity is in use: - The intent is to produce an image that portrays clear areas against a dark backdrop. - The initial state of the entire image plane is dark, as opposed to being clear. - The polarity effects between dark and clear regions are interchanged. Essentially, what was dark becomes white and vice-versa. - For negative image polarity, the very first graphics object that gets produced must possess a dark polarity. As a result, it takes on the role of clearing the dark backdrop.

Source code in src/pygerber/gerberx3/state_enums.py
class ImagePolarityEnum(EnumFormatValue):
    """Image polarity.

    ### Image Polarity (IP)

    Note: The IP command is deprecated.

    The `IP` command is responsible for setting the polarity for the entire image. It is
    designed to be used only once, preferably at the very beginning of the file.

    #### 7.1.3.1 Positive Image Polarity
    Under the positive image polarity:
    - The image is generated in accordance with the specifications provided elsewhere in
        this document.
    - It's worth noting that, by default, image generation has always assumed a positive
        image polarity.

    #### 7.1.3.2 Negative Image Polarity
    When the negative image polarity is in use:
    - The intent is to produce an image that portrays clear areas against a dark
        backdrop.
    - The initial state of the entire image plane is dark, as opposed to being clear.
    - The polarity effects between dark and clear regions are interchanged. Essentially,
        what was dark becomes white and vice-versa.
    - For negative image polarity, the very first graphics object that gets produced
        must possess a dark polarity. As a result, it takes on the role of clearing the
        dark backdrop.
    """

    POSITIVE = "POS"
    NEGATIVE = "NEG"