Welcome to Cirkuix’s documentation!¶
Contents:
- class cirkuix.App¶
The main application class. The constructor starts the GUI.
- adjust_axes(xmin, ymin, xmax, ymax)¶
Adjusts axes of all plots while maintaining the use of the whole canvas and an aspect ratio to 1:1 between x and y axes. The parameters are an original request that will be modified to fit these restrictions.
Parameters: - xmin (float) – Requested minimum value for the X axis.
- ymin (float) – Requested minimum value for the Y axis.
- xmax (float) – Requested maximum value for the X axis.
- ymax (float) – Requested maximum value for the Y axis.
Returns: None
- build_list()¶
Clears and re-populates the list of objects in currently in the project.
Returns: None
- clear_plots()¶
Clears self.axes and self.figure.
Returns: None
- file_chooser_action(on_success)¶
Opens the file chooser and runs on_success on a separate thread upon completion of valid file choice.
Parameters: on_success (func) – A function to run upon completion of a valid file selection. Takes 2 parameters: The app instance and the filename. Note that it is run on a separate thread, therefore it must take the appropriate precautions when accessing shared resources. Returns: None
- file_chooser_save_action(on_success)¶
Opens the file chooser and runs on_success upon completion of valid file choice.
Parameters: on_success – A function to run upon selection of a filename. Takes 2 parameters: The instance of the application (App) and the chosen filename. This gets run immediately in the same thread. Returns: None
- get_current()¶
Returns the currently selected CirkuixObj in the application.
Returns: Currently selected CirkuixObj in the application. Return type: CirkuixObj or None
- get_eval(widget_name)¶
Runs eval() on the on the text entry of name ‘widget_name’ and returns the results.
Parameters: widget_name (str) – Name of Gtk.Entry Returns: Depends on contents of the entry text.
- get_radio_value(radio_set)¶
Returns the radio_set[key] of the radiobutton whose name is key is active.
Parameters: radio_set (dict) – A dictionary containing widget_name: value pairs. Returns: radio_set[key]
- info(text)¶
Show text on the status bar.
Parameters: text (str) – Text to display. Returns: None
- load_defaults()¶
Loads the aplication’s default settings from defaults.json into self.defaults.
Returns: 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.
Parameters: entry – The widget from which this was called. Returns: None
- on_canvas_configure(widget, event)¶
Called whenever the canvas changes size. The axes are updated such as to use the whole canvas.
Parameters: - widget – Ignored.
- event – Ignored.
Returns: None
- on_clear_plots(widget)¶
Callback for toolbar button. Clears all plots.
Parameters: widget – The widget from which this was called. Returns: None
- on_click_over_plot(event)¶
Callback for the mouse click event over the plot. This event is generated by the Matplotlib backend and has been registered in self.__init__(). For details, see: http://matplotlib.org/users/event_handling.html
Parameters: event – Returns:
- on_closewindow(param)¶
Callback for closing the main window.
Parameters: param – Whatever is passed by the event. Ignore. Returns: None
- on_cncjob_exportgcode(widget)¶
Called from button on CNCjob form to save the G-Code from the object.
Parameters: widget – The widget from which this was called. Returns: None
- on_delete(widget)¶
Delete the currently selected CirkuixObj.
Parameters: widget – The widget from which this was called. Returns: None
- on_entry_eval_activate(widget)¶
Called when an entry is activated (eg. by hitting enter) if set to do so. Its text is eval()’d and set to the returned value. The current object is updated.
Parameters: widget – Returns:
- on_eval_update(widget)¶
Modifies the content of a Gtk.Entry by running eval() on its contents and puting it back as a string.
Parameters: widget – The widget from which this was called. Returns: None
- on_excellon_tool_choose(widget)¶
Callback for button on Excellon form to open up a window for selecting tools.
Parameters: widget – The widget from which this was called. Returns: None
- on_file_new(param)¶
Callback for menu item File->New. Returns the application to its startup state.
Parameters: param – Whatever is passed by the event. Ignore. Returns: None
- on_file_savedefaults(param)¶
Callback for menu item File->Save Defaults. Saves application default options (self.defaults) to defaults.json.
Parameters: param – Ignored. Returns: None
- on_fileopenexcellon(param)¶
Callback for menu item File->Open Excellon. Defines a function that is then passed to self.file_chooser_action(). It requests the creation of a CirkuixExcellon object and updates the progress bar throughout the process.
Parameters: param – Ignore Returns: None
- on_fileopengcode(param)¶
Callback for menu item File->Open G-Code. Defines a function that is then passed to self.file_chooser_action(). It requests the creation of a CirkuixCNCjob object and updates the progress bar throughout the process.
Parameters: param – Ignore Returns: None
- on_fileopengerber(param)¶
Callback for menu item File->Open Gerber. Defines a function that is then passed to self.file_chooser_action(). It requests the creation of a CirkuixGerber object and updates the progress bar throughout the process.
Parameters: param – Ignore Returns: None
- on_filequit(param)¶
Callback for menu item File->Quit. Closes the application.
Parameters: param – Whatever is passed by the event. Ignore. Returns: None
- on_generate_cncjob(widget)¶
Callback for button on geometry form to generate CNC job.
Parameters: widget – The widget from which this was called. Returns: None
- on_generate_excellon_cncjob(widget)¶
Callback for button active/click on Excellon form to create a CNC Job for the Excellon file.
Parameters: widget – The widget from which this was called. Returns: None
- on_generate_gerber_bounding_box(widget)¶
Callback for request from the Gerber form to generate a bounding box for the geometry in the object. Creates a CirkuixGeometry with the bounding box.
Parameters: widget – Ignored. Returns: None
- on_generate_isolation(widget)¶
Callback for button on Gerber form to create isolation routing geometry.
Parameters: widget – The widget from which this was called. Returns: 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.
Parameters: widget – The widget from which this was called. Returns: None
- on_gerber_generate_cutout(widget)¶
Callback for button on Gerber form to create geometry with lines for cutting off the board.
Parameters: widget – The widget from which this was called. Returns: 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.
Parameters: widget – The widget from which this was called. Returns: None
- on_key_over_plot(event)¶
Callback for the key pressed event when the canvas is focused. Keyboard shortcuts are handled here. So far, these are the shortcuts:
Key Action ‘1’ Zoom-fit. Fits the axes limits to the data. ‘2’ Zoom-out. ‘3’ Zoom-in. Parameters: event – Ignored. Returns: None
- on_mouse_move_over_plot(event)¶
Callback for the mouse motion event over the plot. This event is generated by the Matplotlib backend and has been registered in self.__init__(). For details, see: http://matplotlib.org/users/event_handling.html
Parameters: event – Contains information about the event. Returns: None
- on_options_app2object(param)¶
Callback for Options->Transfer Options->App=>Object. Copies options from application defaults to the currently selected object.
Parameters: param – Ignored. Returns: None
- on_options_app2project(param)¶
Callback for Options->Transfer Options->App=>Project. Copies options from application defaults to project defaults.
Parameters: param – Ignored. Returns: None
- on_options_combo_change(widget)¶
Called when the combo box to choose between application defaults and project option changes value. The corresponding variables are copied to the UI.
Parameters: widget – The widget from which this was called. Ignore. Returns: None
- on_options_object2app(param)¶
Callback for Options->Transfer Options->Object=>App. Copies options from the currently selected object to application defaults.
Parameters: param – Ignored. Returns: None
- on_options_object2project(param)¶
Callback for Options->Transfer Options->Object=>Project. Copies options from the currently selected object to project defaults.
Parameters: param – Ignored. Returns: None
- on_options_project2app(param)¶
Callback for Options->Transfer Options->Project=>App. Copies options from project defaults to application defaults.
Parameters: param – Ignored. Returns: None
- on_options_project2object(param)¶
Callback for Options->Transfer Options->Project=>Object. Copies options from project defaults to the currently selected object.
Parameters: param – Ignored. Returns: None
- on_options_update(widget)¶
Called whenever a value in the options/defaults form changes. All values are updated. Can be inhibited by setting self.options_update_ignore = True, which may be necessary when updating the UI from code and not by the user.
Parameters: widget – The widget from which this was called. Ignore. Returns: None
- on_replot(widget)¶
Callback for toolbar button. Re-plots all objects.
Parameters: widget – The widget from which this was called. Returns: None
- on_row_activated(widget, path, col)¶
Callback for selection activation (Enter or double-click) on the Project list. Switches the notebook page to the object properties form. Calls self.notebook.set_current_page(1).
Parameters: - widget – Ignored.
- path – Ignored.
- col – Ignored.
Returns: None
- on_scale_object(widget)¶
Callback for request to change an objects geometry scale. The object is re-scaled and replotted.
Parameters: widget – Ignored. Returns: None
- on_tree_selection_changed(selection)¶
Callback for selection change in the project list. This changes the currently selected CirkuixObj.
Parameters: selection (Gtk.TreeSelection) – Selection associated to the project tree or list Returns: None
- on_update_plot(widget)¶
Callback for button on form for all kinds of objects. Re-plots the current object only.
Parameters: widget – The widget from which this was called. Returns: None
- on_zoom_fit(event)¶
Callback for zoom-out request. This can be either from the corresponding toolbar button or the ‘1’ key when the canvas is focused. Calls self.adjust_axes() with axes limits from the geometry bounds of all objects.
Parameters: event – Ignored. Returns: None
- on_zoom_in(event)¶
Callback for zoom-in request. This can be either from the corresponding toolbar button or the ‘3’ key when the canvas is focused. Calls self.zoom().
Parameters: event – Ignored. Returns: None
- on_zoom_out(event)¶
Callback for zoom-out request. This can be either from the corresponding toolbar button or the ‘2’ key when the canvas is focused. Calls self.zoom().
Parameters: event – Ignored. Returns: None
- options2form()¶
Sets the ‘Project Options’ or ‘Application Defaults’ form with values from self.options``or ``self.defaults. :return : None :rtype : None
- plot_all()¶
Re-generates all plots from all objects.
Returns: None
- read_form()¶
Reads the options form into self.defaults/self.options.
Returns: None Return type: None
- read_form_item(name, dest)¶
Reads the value of a form item in the defaults/options form and saves it to the corresponding dictionary.
Parameters: - name (str) – Name of the form item. A key in self.defaults or self.options.
- dest (dict) – Dictionary to which to save the value.
Returns: None
- set_form_item(name, value)¶
Sets a form item ‘name’ in the GUI with the given ‘value’. The syntax of form names in the GUI is <kind>_app_<name>, where kind is one of: rb (radio button), cb (check button), entry_eval or entry_text (entry), combo (combo box). name is whatever name it’s been given. For self.defaults, name is a key in the dictionary.
Parameters: - name (str) – Name of the form field.
- value (Depends on field kind.) – The value to set the form field to.
Returns: 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().
Parameters: name (str) – Name of the object. Returns: None
- set_progress_bar(percentage, text='')¶
Sets the application’s progress bar to a given fraction and text.
Parameters: - percentage (float) – The fraction (0.0-1.0) of the progress.
- text (str) – Text to display on the progress bar.
Returns:
- 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.
Returns: None
- setup_obj_classes()¶
Sets up application specifics on the CirkuixObj class.
Returns: 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.
Returns: None Return type: None
- setup_project_list()¶
Sets up list or Tree where whatever has been loaded or created is displayed.
Returns: None
- zoom(factor, center=None)¶
Zooms the plot by factor around a given center point. Takes care of re-drawing.
Parameters: - factor (float) – Number by which to scale the plot.
- center (list) – Coordinates [x, y] of the point around which to scale the plot.
Returns: 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.