diff --git a/FlatCAM.py b/FlatCAM.py index 98bb3e22..457aa374 100644 --- a/FlatCAM.py +++ b/FlatCAM.py @@ -5,7 +5,12 @@ ############################################################ import threading -from gi.repository import Gtk, Gdk, GLib, GObject + +# TODO: Bundle together. This is just for debugging. +from gi.repository import Gtk +from gi.repository import Gdk +from gi.repository import GLib +from gi.repository import GObject import simplejson as json from matplotlib.figure import Figure @@ -534,7 +539,7 @@ class App: def __init__(self): """ - Starts the application. + Starts the application. Takes no parameters. :return: app :rtype: App @@ -2291,6 +2296,7 @@ class App: assert isinstance(gerber_obj, FlatCAMGerber) GLib.idle_add(lambda: app_obj.set_progress_bar(0.2, "Parsing ...")) gerber_obj.parse_file(filename) + GLib.idle_add(lambda: app_obj.set_progress_bar(0.5, "Creating Geometry ...")) gerber_obj.create_geometry() GLib.idle_add(lambda: app_obj.set_progress_bar(0.6, "Plotting ...")) diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..b3934d10 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Juan Pablo Caram + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/README b/README index 224d08ba..e3db5742 100644 --- a/README +++ b/README @@ -1,4 +1,19 @@ -Requirements: -1) GTK+ 3 -2) Shapely -3) PyObjects (Python GI API) \ No newline at end of file +FlatCAM: 2D Post-processinf for Manufacturing +============================================= + +(c) 2014 Juan Pablo Caram + +FlatCAM is a program for preparing CNC jobs for making PCBs on a CNC router. +Among other things, it can take a Gerber file generated by your favorite PCB +CAD program, and create G-Code for Isolation routing. But there's more. See +the features list below. + +* Powerful user interface for visualization. +* Viewers for: Gerber, Excellon, G-Code. +* Create isolation routing geometry from Gerber. +* Create optimized G-Code from geometry. +* Double sided PCB tools. +* Clearing copper areas. +* Measuring tool (planned). +* PCB cutout tool. +* Table flattening tool. \ No newline at end of file diff --git a/camlib.py b/camlib.py index 87f4ea0a..f263bf26 100644 --- a/camlib.py +++ b/camlib.py @@ -22,7 +22,8 @@ from shapely.geometry.base import BaseGeometry from descartes.patch import PolygonPatch import simplejson as json -from matplotlib.pyplot import plot +# TODO: Commented for FlatCAM packaging with cx_freeze +#from matplotlib.pyplot import plot class Geometry: def __init__(self): @@ -210,7 +211,12 @@ class Gerber (Geometry): *buffering* (or thickening) the ``paths`` with the aperture. These are generated from ``paths`` in ``buffer_paths()``. - **USAGE** + **USAGE**:: + + g = Gerber() + g.parse_file(filename) + g.create_geometry() + do_something(s.solid_geometry) """ @@ -330,8 +336,12 @@ class Gerber (Geometry): * *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. + * *Obround (O)*: width (float), height (float). + + :param gline: Line of Gerber code known to have an aperture definition. + :type gline: str + :return: Identifier of the aperture. + :rtype: str """ indexstar = gline.find("*") indexc = gline.find("C,") @@ -465,7 +475,23 @@ class Gerber (Geometry): rectangle = shply_box(minx, miny, maxx, maxy) self.flash_geometry.append(rectangle) continue - #TODO: Add support for type='O' + if aperture['type'] == 'O': # Obround + loc = flash['loc'] + width = aperture['width'] + height = aperture['height'] + if width > height: + p1 = Point(loc[0] + 0.5*(width-height), loc[1]) + p2 = Point(loc[0] - 0.5*(width-height), loc[1]) + c1 = p1.buffer(height*0.5) + c2 = p2.buffer(height*0.5) + else: + p1 = Point(loc[0], loc[1] + 0.5*(height-width)) + p2 = Point(loc[0], loc[1] - 0.5*(height-width)) + c1 = p1.buffer(width*0.5) + c2 = p2.buffer(width*0.5) + obround = cascaded_union([c1, c2]).convex_hull + self.flash_geometry.append(obround) + continue print "WARNING: Aperture type %s not implemented" % (aperture['type']) def create_geometry(self): @@ -480,9 +506,13 @@ class Gerber (Geometry): """ # if len(self.buffered_paths) == 0: # self.buffer_paths() + print "... buffer_paths()" self.buffer_paths() + print "... fix_regions()" self.fix_regions() + print "... do_flashes()" self.do_flashes() + print "... cascaded_union()" self.solid_geometry = cascaded_union( self.buffered_paths + [poly['polygon'] for poly in self.regions] + @@ -495,7 +525,7 @@ class Gerber (Geometry): can optionally have rounded corners of radius equal to margin. :param margin: Distance to enlarge the rectangular bounding - box in both positive and negative, x and y axes. + box in both positive and negative, x and y axes. :type margin: float :param rounded: Wether or not to have rounded corners. :type rounded: bool diff --git a/doc/build/.doctrees/environment.pickle b/doc/build/.doctrees/environment.pickle index 71d6ddaf..67d7187d 100644 Binary files a/doc/build/.doctrees/environment.pickle and b/doc/build/.doctrees/environment.pickle differ diff --git a/doc/build/.doctrees/index.doctree b/doc/build/.doctrees/index.doctree index 9acf5957..c379cf24 100644 Binary files a/doc/build/.doctrees/index.doctree and b/doc/build/.doctrees/index.doctree differ diff --git a/doc/build/_sources/index.txt b/doc/build/_sources/index.txt index 4b57240f..62096bdb 100644 --- a/doc/build/_sources/index.txt +++ b/doc/build/_sources/index.txt @@ -13,7 +13,7 @@ Contents: .. toctree:: :maxdepth: 2 -.. automodule:: cirkuix +.. automodule:: FlatCAM .. autoclass:: App :members: @@ -30,19 +30,19 @@ Contents: .. autoclass:: CNCjob :members: -.. autoclass:: CirkuixObj +.. autoclass:: FlatCAMObj :members: -.. autoclass:: CirkuixGerber +.. autoclass:: FlatCAMGerber :members: -.. autoclass:: CirkuixExcellon +.. autoclass:: FlatCAMExcellon :members: -.. autoclass:: CirkuixCNCjob +.. autoclass:: FlatCAMCNCjob :members: -.. autoclass:: CirkuixGeometry +.. autoclass:: FlatCAMGeometry :members: diff --git a/doc/build/genindex.html b/doc/build/genindex.html index 04802a57..025eb7e2 100644 --- a/doc/build/genindex.html +++ b/doc/build/genindex.html @@ -138,17 +138,17 @@