Welcome to Cirkuix’s documentation!

Contents:

class cirkuix.App

The main application class. The constructor starts the GUI.

build_list()

Clears and re-populates the list of objects in currently in the project. @return: None

clear_plots()

Clears self.axes and self.figure. @return: None

file_chooser_action(on_success)

Opens the file chooser and runs on_success on a separate thread upon completion of valid file choice.

file_chooser_save_action(on_success)

Opens the file chooser and runs on_success upon completion of valid file choice.

get_current()

Returns the currently selected CirkuixObj in the application. @return: Currently selected CirkuixObj in the application. @rtype: CirkuixObj

get_eval(widget_name)

Runs eval() on the on the text entry of name ‘widget_name’ and returns the results. @param widget_name: Name of Gtk.Entry @return: Depends on contents of the entry text.

get_radio_value(radio_set)

Returns the radio_set[key] if the radiobutton whose name is key is active. @return: radio_set[key]

info(text)

Show text on the status bar. @return: None

new_object(kind, name, initialize)

Creates a new specalized CirkuixObj and attaches it to the application, this is, updates the GUI accordingly, any other records and plots it.

Parameters:
  • kind (str) – The kind of object to create. One of ‘gerber’, ‘excellon’, ‘cncjob’ and ‘geometry’.
  • name (str) – Name for the object.
  • initialize (function) – Function to run after creation of the object but before it is attached to the application. The function is called with 2 parameters: the new object and the App instance.
Returns:

None

Return type:

None

on_activate_name(entry)

Hitting ‘Enter’ after changing the name of an item updates the item dictionary and re-builds the item list.

on_delete(widget)

Delete the currently selected CirkuixObj. @param widget: The widget from which this was called. @return:

on_eval_update(widget)

Modifies the content of a Gtk.Entry by running eval() on its contents and puting it back as a string. @param widget: The widget from which this was called. @return: None

on_excellon_tool_choose(widget)

Callback for button on Excellon form to open up a window for selecting tools. @param widget: The widget from which this was called. @return: None

on_generate_cncjob(widget)

Callback for button on geometry form to generate CNC job. @param widget: The widget from which this was called. @return: None

on_generate_excellon_cncjob(widget)

Callback for button active/click on Excellon form to create a CNC Job for the Excellon file. @param widget: The widget from which this was called. @return: None

on_generate_isolation(widget)

Callback for button on Gerber form to create isolation routing geometry. @param widget: The widget from which this was called. @return: None

on_generate_paintarea(widget)

Callback for button on geometry form. Subscribes to the “Click on plot” event and continues after the click. Finds the polygon containing the clicked point and runs clear_poly() on it, resulting in a new CirkuixGeometry object.

on_gerber_generate_cutout(widget)

Callback for button on Gerber form to create geometry with lines for cutting off the board. @param widget: The widget from which this was called. @return: None

on_gerber_generate_noncopper(widget)

Callback for button on Gerber form to create a geometry object with polygons covering the area without copper or negative of the Gerber. @param widget: The widget from which this was called. @return: None

on_tree_selection_changed(selection)

Callback for selection change in the project list. This changes the currently selected CirkuixObj. @param selection: Selection associated to the project tree or list @type selection: Gtk.TreeSelection @return: None

on_update_plot(widget)

Callback for button on form for all kinds of objects. Re-plot the current object only. @param widget: The widget from which this was called. @return: None

plot_all()

Re-generates all plots from all objects. @return: None

set_list_selection(name)

Marks a given object as selected in the list ob objects in the GUI. This selection will in turn trigger self.on_tree_selection_changed(). @param name: Name of the object. @return: None

setup_component_editor()

Initial configuration of the component editor. Creates a page titled “Selection” on the notebook on the left side of the main window. @return: None

setup_component_viewer()

Sets up list or Tree where whatever has been loaded or created is displayed. @return: None

setup_plot()

Sets up the main plotting area by creating a matplotlib figure in self.canvas, adding axes and configuring them. These axes should not be ploted on and are just there to display the axes ticks and grid. @return: None

zoom(factor, center=None)

Zooms the plot by factor around a given center point. Takes care of re-drawing. @return: None

class cirkuix.Geometry
bounds()

Returns coordinates of rectangular bounds of geometry: (xmin, ymin, xmax, ymax).

clear_polygon(polygon, tooldia, overlap=0.15)

Creates geometry inside a polygon for a tool to cover the whole area.

convert_units(units)

Converts the units of the object to units by scaling all the geometry appropriately.

Parameters:units (str) – “IN” or “MM”
Returns:Scaling factor resulting from unit change.
Return type:float
get_empty_area(boundary=None)

Returns the complement of self.solid_geometry within the given boundary polygon. If not specified, it defaults to the rectangular bounding box of self.solid_geometry.

isolation_geometry(offset)

Creates contours around geometry at a given offset distance.

scale(factor)

Scales all of the object’s geometry by a given factor. Override this method. :param factor: Number by which to scale. :type factor: float :return: None :rtype: None

size()

Returns (width, height) of rectangular bounds of geometry.

class cirkuix.Gerber(Geometry)

ATTRIBUTES

  • apertures (dict): The keys are names/identifiers of each aperture. The values are dictionaries key/value pairs which describe the aperture. The type key is always present and the rest depend on the key:
Key Value
type (str) “C”, “R”, or “O”
others Depend on type
  • paths (list): A path is described by a line an aperture that follows that line. Each paths[i] is a dictionary:
Key Value
linestring (Shapely.LineString) The actual path.
aperture (str) The key for an aperture in apertures.
  • flashes (list): Flashes are single-point strokes of an aperture. Each is a dictionary:
Key Value
loc (list) [x (float), y (float)] coordinates.
aperture (str) The key for an aperture in apertures.
  • regions (list): Are surfaces defined by a polygon (Shapely.Polygon), which have an exterior and zero or more interiors. An aperture is also associated with a region. Each is a dictionary:
Key Value
polygon (Shapely.Polygon) The polygon defining the region.
aperture (str) The key for an aperture in apertures.
  • flash_geometry (list): List of (Shapely) geometric object resulting from flashes. These are generated from flashes in do_flashes().
  • buffered_paths (list): List of (Shapely) polygons resulting from buffering (or thickening) the paths with the aperture. These are generated from paths in buffer_paths().
aperture_parse(gline)

Parse gerber aperture definition into dictionary of apertures. The following kinds and their attributes are supported:

  • Circular (C): size (float)
  • Rectangle (R): width (float), height (float)
  • Obround (O): width (float), height (float). NOTE: This can be parsed, but it is not supported further yet.
create_geometry()

Geometry from a Gerber file is made up entirely of polygons. Every stroke (linear or circular) has an aperture which gives it thickness. Additionally, aperture strokes have non-zero area, and regions naturally do as well. :rtype : None @return: None

digits = None

Number of integer digits in Gerber numbers. Used during parsing.

do_flashes()

Creates geometry for Gerber flashes (aperture on a single point).

fix_regions()

Overwrites the region polygons with fixed versions if found to be invalid (according to Shapely).

fraction = None

Number of fraction digits in Gerber numbers. Used during parsing.

parse_file(filename)

Calls Gerber.parse_lines() with array of lines read from the given file.

parse_lines(glines)

Main Gerber parser.

scale(factor)

Scales the objects’ geometry on the XY plane by a given factor. These are:

  • apertures
  • paths
  • regions
  • flashes

Then buffered_paths, flash_geometry and solid_geometry are re-created with self.create_geometry(). :param factor: Number by which to scale. :type factor: float :rtype : None

class cirkuix.Excellon

ATTRIBUTES

  • tools (dict): The key is the tool name and the value is the size (diameter).
  • drills (list): Each is a dictionary:
Key Value
point (Shapely.Point) Where to drill
tool (str) A key in tools
parse_lines(elines)

Main Excellon parser.

scale(factor)

Scales geometry on the XY plane in the object by a given factor. Tool sizes, feedrates an Z-plane dimensions are untouched. :param factor: Number by which to scale the object. :type factor: float :return: None :rtype: NOne

class cirkuix.CNCjob(units='in', kind='generic', z_move=0.1, feedrate=3.0, z_cut=-0.002, tooldia=0.0)

Represents work to be done by a CNC machine.

ATTRIBUTES

  • gcode_parsed (list): Each is a dictionary:
Key Value
geom (Shapely.LineString) Tool path (XY plane)
kind (string) “AB”, A is “T” (travel) or “C” (cut). B is “F” (fast) or “S” (slow).
gcode_parse()

G-Code parser (from self.gcode). Generates dictionary with single-segment LineString’s and “kind” indicating cut or travel, fast or feedrate speed.

generate_from_excellon(exobj)

Generates G-code for drilling from Excellon object. self.gcode becomes a list, each element is a different job for each tool in the excellon code.

generate_from_excellon_by_tool(exobj, tools='all')

Creates gcode for this object from an Excellon object for the specified tools. @param exobj: Excellon object to process @type exobj: Excellon @param tools: Comma separated tool names @type: tools: str @return: None

generate_from_geometry(geometry, append=True, tooldia=None)

Generates G-Code from a Geometry object.

plot(tooldia=None, dpi=75, margin=0.1, color={'C': ['#5E6CFF', '#4650BD'], 'T': ['#F0E24D', '#B5AB3A']}, alpha={'C': 1.0, 'T': 0.3})

Creates a Matplotlib figure with a plot of the G-code job.

plot2(axes, tooldia=None, dpi=75, margin=0.1, color={'C': ['#5E6CFF', '#4650BD'], 'T': ['#F0E24D', '#B5AB3A']}, alpha={'C': 1.0, 'T': 0.3})

Plots the G-code job onto the given axes.

polygon2gcode(polygon)

Creates G-Code for the exterior and all interior paths of a polygon. @param polygon: A Shapely.Polygon @type polygon: Shapely.Polygon

pre_parse(gtext)

gtext is a single string with g-code

scale(factor)

Scales all the geometry on the XY plane in the object by the given factor. Tool sizes, feedrates, or Z-axis dimensions are not altered. :param factor: Number by which to scale the object. :type factor: float :return: None :rtype: None

class cirkuix.CirkuixObj(name)

Base type of objects handled in Cirkuix. These become interactive in the GUI, can be plotted, and their options can be modified by the user in their respective forms.

build_ui()

Sets up the UI/form for this object. @return: None @rtype : None

deserialize(obj_dict)

Re-builds an object from its serialized version. @param obj_dict: Dictionary representing a CirkuixObj @type obj_dict: dict @return None

plot(figure)

Extend this method! Sets up axes if needed and clears them. Descendants must do the actual plotting.

read_form()

Reads form into self.options @rtype : None

serialize()

Returns a representation of the object as a dictionary so it can be later exported as JSON. Override this method. @return: Dictionary representing the object @rtype: dict

setup_axes(figure)

1) Creates axes if they don’t exist. 2) Clears axes. 3) Attaches them to figure if not part of the figure. 4) Sets transparent background. 5) Sets 1:1 scale aspect ratio. @param figure: A Matplotlib.Figure on which to add/configure axes. @type figure: matplotlib.figure.Figure @return: None

class cirkuix.CirkuixGerber(name)

Represents Gerber code.

class cirkuix.CirkuixExcellon(name)

Represents Excellon code.

class cirkuix.CirkuixCNCjob(name, units='in', kind='generic', z_move=0.1, feedrate=3.0, z_cut=-0.002, tooldia=0.0)

Represents G-Code.

class cirkuix.CirkuixGeometry(name)

Geometric object not associated with a specific format.

Indices and tables