Fixed bug in Excellon parser. Did not support numbers with period.

This commit is contained in:
Juan Pablo Caram
2014-03-03 22:12:07 -05:00
parent 49c8aeb723
commit ad5e989331
3 changed files with 1721 additions and 1214 deletions

View File

@@ -19,8 +19,7 @@ import simplejson as json
from matplotlib.figure import Figure from matplotlib.figure import Figure
from numpy import arange, sin, pi from numpy import arange, sin, pi
from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg as FigureCanvas from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg as FigureCanvas
#from matplotlib.backends.backend_gtk3cairo import FigureCanvasGTK3Cairo as FigureCanvas from mpl_toolkits.axes_grid.anchored_artists import AnchoredText
#from matplotlib.backends.backend_cairo import FigureCanvasCairo as FigureCanvas
from camlib import * from camlib import *
import sys import sys
@@ -552,11 +551,23 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
return factor return factor
def plot(self, figure): def plot(self, figure):
"""
Plots the object onto the give figure. Updates the canvas
when done.
:param figure: Matplotlib figure on which to plot.
:type figure: Matplotlib.Figure
:return: None
"""
# Sets up and clears self.axes.
# Attaches axes to the figure... Maybe we want to do that
# when plotting is complete?
FlatCAMObj.plot(self, figure) FlatCAMObj.plot(self, figure)
if not self.options["plot"]: if not self.options["plot"]:
return return
# Make sure solid_geometry is iterable.
try: try:
_ = iter(self.solid_geometry) _ = iter(self.solid_geometry)
except TypeError: except TypeError:
@@ -611,6 +622,8 @@ class App:
# Needed to interact with the GUI from other threads. # Needed to interact with the GUI from other threads.
GObject.threads_init() GObject.threads_init()
# GLib.log_set_handler()
#### GUI #### #### GUI ####
self.gladefile = "FlatCAM.ui" self.gladefile = "FlatCAM.ui"
self.builder = Gtk.Builder() self.builder = Gtk.Builder()
@@ -634,6 +647,8 @@ class App:
self.setup_project_list() # The "Project" tab self.setup_project_list() # The "Project" tab
self.setup_component_editor() # The "Selected" tab self.setup_component_editor() # The "Selected" tab
self.setup_toolbar()
#### Event handling #### #### Event handling ####
self.builder.connect_signals(self) self.builder.connect_signals(self)
@@ -688,7 +703,14 @@ class App:
# self.radios.update({obj.kind + "_" + option: obj.radios[option]}) # self.radios.update({obj.kind + "_" + option: obj.radios[option]})
# self.radios_inv.update({obj.kind + "_" + option: obj.radios_inv[option]}) # self.radios_inv.update({obj.kind + "_" + option: obj.radios_inv[option]})
## Event subscriptions ##
self.plot_click_subscribers = {} self.plot_click_subscribers = {}
self.plot_mousemove_subscribers = {}
## Tools ##
self.measure = Measurement(self.axes, self.plot_click_subscribers,
self.plot_mousemove_subscribers,
lambda: self.canvas.queue_draw())
#### Initialization #### #### Initialization ####
self.load_defaults() self.load_defaults()
@@ -697,13 +719,13 @@ class App:
self.units_label.set_text("[" + self.options["units"] + "]") self.units_label.set_text("[" + self.options["units"] + "]")
#### Check for updates #### #### Check for updates ####
self.version = 1 self.version = 2
t1 = threading.Thread(target=self.versionCheck) t1 = threading.Thread(target=self.versionCheck)
t1.daemon = True t1.daemon = True
t1.start() t1.start()
#### For debugging only ### #### For debugging only ###
def someThreadFunc(self): def someThreadFunc(app_obj):
print "Hello World!" print "Hello World!"
t = threading.Thread(target=someThreadFunc, args=(self,)) t = threading.Thread(target=someThreadFunc, args=(self,))
@@ -717,10 +739,55 @@ class App:
self.icon48 = GdkPixbuf.Pixbuf.new_from_file('share/flatcam_icon48.png') self.icon48 = GdkPixbuf.Pixbuf.new_from_file('share/flatcam_icon48.png')
self.icon16 = GdkPixbuf.Pixbuf.new_from_file('share/flatcam_icon16.png') self.icon16 = GdkPixbuf.Pixbuf.new_from_file('share/flatcam_icon16.png')
Gtk.Window.set_default_icon_list([self.icon16, self.icon48, self.icon256]) Gtk.Window.set_default_icon_list([self.icon16, self.icon48, self.icon256])
self.window.set_title("FlatCAM - Alpha 2 UNSTABLE - Check for updates!") self.window.set_title("FlatCAM - Alpha 3 UNSTABLE - Check for updates!")
self.window.set_default_size(900, 600) self.window.set_default_size(900, 600)
self.window.show_all() self.window.show_all()
def setup_toolbar(self):
toolbar = self.builder.get_object("toolbar_main")
# Zoom fit
zf_ico = Gtk.Image.new_from_file('share/zoom_fit32.png')
zoom_fit = Gtk.ToolButton.new(zf_ico, "")
zoom_fit.connect("clicked", self.on_zoom_fit)
zoom_fit.set_tooltip_markup("Zoom Fit.\n(Click on plot and hit <b>1</b>)")
toolbar.insert(zoom_fit, -1)
# Zoom out
zo_ico = Gtk.Image.new_from_file('share/zoom_out32.png')
zoom_out = Gtk.ToolButton.new(zo_ico, "")
zoom_out.connect("clicked", self.on_zoom_out)
zoom_out.set_tooltip_markup("Zoom Out.\n(Click on plot and hit <b>2</b>)")
toolbar.insert(zoom_out, -1)
# Zoom in
zi_ico = Gtk.Image.new_from_file('share/zoom_in32.png')
zoom_in = Gtk.ToolButton.new(zi_ico, "")
zoom_in.connect("clicked", self.on_zoom_in)
zoom_in.set_tooltip_markup("Zoom In.\n(Click on plot and hit <b>3</b>)")
toolbar.insert(zoom_in, -1)
# Clear plot
cp_ico = Gtk.Image.new_from_file('share/clear_plot32.png')
clear_plot = Gtk.ToolButton.new(cp_ico, "")
clear_plot.connect("clicked", self.on_clear_plots)
clear_plot.set_tooltip_markup("Clear Plot")
toolbar.insert(clear_plot, -1)
# Replot
rp_ico = Gtk.Image.new_from_file('share/replot32.png')
replot = Gtk.ToolButton.new(rp_ico, "")
replot.connect("clicked", self.on_toolbar_replot)
replot.set_tooltip_markup("Re-plot all")
toolbar.insert(replot, -1)
# Delete item
del_ico = Gtk.Image.new_from_file('share/delete32.png')
delete = Gtk.ToolButton.new(del_ico, "")
delete.connect("clicked", self.on_delete)
delete.set_tooltip_markup("Delete selected\nobject.")
toolbar.insert(delete, -1)
def setup_plot(self): def setup_plot(self):
""" """
Sets up the main plotting area by creating a Matplotlib Sets up the main plotting area by creating a Matplotlib
@@ -1403,6 +1470,9 @@ class App:
for widget in tooltips: for widget in tooltips:
self.builder.get_object(widget).set_tooltip_markup(tooltips[widget]) self.builder.get_object(widget).set_tooltip_markup(tooltips[widget])
def do_nothing(self, param):
return
######################################## ########################################
## EVENT HANDLERS ## ## EVENT HANDLERS ##
######################################## ########################################
@@ -2284,6 +2354,7 @@ class App:
assert isinstance(app_obj, App) assert isinstance(app_obj, App)
cp = clear_poly(poly.buffer(-geo.options["paintmargin"]), tooldia, overlap) cp = clear_poly(poly.buffer(-geo.options["paintmargin"]), tooldia, overlap)
geo_obj.solid_geometry = cp geo_obj.solid_geometry = cp
geo_obj.options["cnctooldia"] = tooldia
name = self.selected_item_name + "_paint" name = self.selected_item_name + "_paint"
self.new_object("geometry", name, gen_paintarea) self.new_object("geometry", name, gen_paintarea)
@@ -2628,6 +2699,10 @@ class App:
self.position_label.set_label("X: %.4f Y: %.4f" % ( self.position_label.set_label("X: %.4f Y: %.4f" % (
event.xdata, event.ydata)) event.xdata, event.ydata))
self.mouse = [event.xdata, event.ydata] self.mouse = [event.xdata, event.ydata]
for subscriber in self.plot_mousemove_subscribers:
self.plot_mousemove_subscribers[subscriber](event)
except: except:
self.position_label.set_label("") self.position_label.set_label("")
self.mouse = None self.mouse = None
@@ -2743,6 +2818,240 @@ class App:
self.zoom(1.5, self.mouse) self.zoom(1.5, self.mouse)
return return
if event.key == 'm':
if self.measure.toggle_active():
self.info("Measuring tool ON")
else:
self.info("Measuring tool OFF")
return
class Measurement:
def __init__(self, axes, click_subscibers, move_subscribers, update=None):
self.update = update
self.axes = axes
self.click_subscribers = click_subscibers
self.move_subscribers = move_subscribers
self.point1 = None
self.point2 = None
self.active = False
self.at = None # AnchoredText object on plot
def toggle_active(self):
if self.active:
self.active = False
self.move_subscribers.pop("meas")
self.click_subscribers.pop("meas")
self.at.remove()
if self.update is not None:
self.update()
return False
else:
self.active = True
self.click_subscribers["meas"] = self.on_click
self.move_subscribers["meas"] = self.on_move
return True
def on_move(self, event):
try:
self.at.remove()
except:
pass
if self.point1 is None:
self.at = AnchoredText("Click on a reference point...")
else:
dx = event.xdata - self.point1[0]
dy = event.ydata - self.point1[1]
d = sqrt(dx**2 + dy**2)
self.at = AnchoredText("D = %.4f\nD(x) = %.4f\nD(y) = %.4f" % (d, dx, dy),
loc=2, prop={'size': 14}, frameon=False)
self.axes.add_artist(self.at)
if self.update is not None:
self.update()
def on_click(self, event):
if self.point1 is None:
self.point1 = (event.xdata, event.ydata)
return
else:
self.point2 = copy.copy(self.point1)
self.point1 = (event.xdata, event.ydata)
class PlotCanvas:
"""
Class handling the plotting area in the application.
"""
def __init__(self, container):
# Options
self.x_margin = 15 # pixels
self.y_margin = 25 # Pixels
# Parent container
self.container = container
# Plots go onto a single matplotlib.figure
self.figure = Figure(dpi=50) # TODO: dpi needed?
self.figure.patch.set_visible(False)
# These axes show the ticks and grid. No plotting done here.
# New axes must have a label, otherwise mpl returns an existing one.
self.axes = self.figure.add_axes([0.05, 0.05, 0.9, 0.9], label="base", alpha=0.0)
self.axes.set_aspect(1)
self.axes.grid(True)
# The canvas is the top level container (Gtk.DrawingArea)
self.canvas = FigureCanvas(self.figure)
self.canvas.set_hexpand(1)
self.canvas.set_vexpand(1)
self.canvas.set_can_focus(True) # For key press
# Attach to parent
self.container.attach(self.canvas, 0, 0, 600, 400)
def mpl_connect(self, event_name, callback):
"""
Attach an event handler to the canvas through the Matplotlib interface.
:param event_name: Name of the event
:type event_name: str
:param callback: Function to call
:type callback: func
:return: Nothing
"""
self.canvas.mpl_connect(event_name, callback)
def connect(self, event_name, callback):
"""
Attach an event handler to the canvas through the native GTK interface.
:param event_name: Name of the event
:type event_name: str
:param callback: Function to call
:type callback: function
:return: Nothing
"""
self.canvas.connect(event_name, callback)
def clear(self):
"""
Clears axes and figure.
:return: None
"""
# Clear
self.axes.cla()
self.figure.clf()
# Re-build
self.figure.add_axes(self.axes)
self.axes.set_aspect(1)
self.axes.grid(True)
# Re-draw
self.canvas.queue_draw()
def adjust_axes(self, 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.
:param xmin: Requested minimum value for the X axis.
:type xmin: float
:param ymin: Requested minimum value for the Y axis.
:type ymin: float
:param xmax: Requested maximum value for the X axis.
:type xmax: float
:param ymax: Requested maximum value for the Y axis.
:type ymax: float
:return: None
"""
width = xmax - xmin
height = ymax - ymin
try:
r = width / height
except:
print "ERROR: Height is", height
return
canvas_w, canvas_h = self.canvas.get_width_height()
canvas_r = float(canvas_w) / canvas_h
x_ratio = float(self.x_margin) / canvas_w
y_ratio = float(self.y_margin) / canvas_h
if r > canvas_r:
ycenter = (ymin + ymax) / 2.0
newheight = height * r / canvas_r
ymin = ycenter - newheight / 2.0
ymax = ycenter + newheight / 2.0
else:
xcenter = (xmax + ymin) / 2.0
newwidth = width * canvas_r / r
xmin = xcenter - newwidth / 2.0
xmax = xcenter + newwidth / 2.0
# Adjust axes
for ax in self.figure.get_axes():
ax.set_xlim((xmin, xmax))
ax.set_ylim((ymin, ymax))
ax.set_position([x_ratio, y_ratio, 1 - 2 * x_ratio, 1 - 2 * y_ratio])
# Re-draw
self.canvas.queue_draw()
def auto_adjust_axes(self):
"""
Calls ``adjust_axes()`` using the extents of the base axes.
:return: None
"""
xmin, xmax = self.axes.get_xlim()
ymin, ymax = self.axes.get_ylim()
self.adjust_axes(xmin, ymin, xmax, ymax)
def zoom(self, factor, center=None):
"""
Zooms the plot by factor around a given
center point. Takes care of re-drawing.
:param factor: Number by which to scale the plot.
:type factor: float
:param center: Coordinates [x, y] of the point around which to scale the plot.
:type center: list
:return: None
"""
xmin, xmax = self.axes.get_xlim()
ymin, ymax = self.axes.get_ylim()
width = xmax - xmin
height = ymax - ymin
if center is None:
center = [(xmin + xmax) / 2.0, (ymin + ymax) / 2.0]
# For keeping the point at the pointer location
relx = (xmax - center[0]) / width
rely = (ymax - center[1]) / height
new_width = width / factor
new_height = height / factor
xmin = center[0] - new_width * (1 - relx)
xmax = center[0] + new_width * relx
ymin = center[1] - new_height * (1 - rely)
ymax = center[1] + new_height * rely
# Adjust axes
for ax in self.figure.get_axes():
ax.set_xlim((xmin, xmax))
ax.set_ylim((ymin, ymax))
# Re-draw
self.canvas.queue_draw()
app = App() app = App()
Gtk.main() Gtk.main()

View File

@@ -6,7 +6,7 @@
<property name="border_width">5</property> <property name="border_width">5</property>
<property name="type_hint">dialog</property> <property name="type_hint">dialog</property>
<property name="program_name">FlatCAM</property> <property name="program_name">FlatCAM</property>
<property name="version">Version Alpha 2 (2014/02) - UNSTABLE</property> <property name="version">Version Alpha 3 (2014/03) - UNSTABLE</property>
<property name="copyright" translatable="yes">(c) 2014 Juan Pablo Caram</property> <property name="copyright" translatable="yes">(c) 2014 Juan Pablo Caram</property>
<property name="comments" translatable="yes">2D Post-processing for Manufacturing specialized in <property name="comments" translatable="yes">2D Post-processing for Manufacturing specialized in
Printed Circuit Boards</property> Printed Circuit Boards</property>
@@ -33,6 +33,7 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.</property> THE SOFTWARE.</property>
<property name="logo">share/flatcam_icon128.png</property>
<child internal-child="vbox"> <child internal-child="vbox">
<object class="GtkBox" id="aboutdialog-vbox1"> <object class="GtkBox" id="aboutdialog-vbox1">
<property name="can_focus">False</property> <property name="can_focus">False</property>
@@ -487,6 +488,22 @@ THE SOFTWARE.</property>
<property name="margin_top">5</property> <property name="margin_top">5</property>
<property name="margin_bottom">5</property> <property name="margin_bottom">5</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<child>
<object class="GtkBox" id="box35">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImage" id="image15">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixbuf">share/cnc32.png</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child> <child>
<object class="GtkLabel" id="label17"> <object class="GtkLabel" id="label17">
<property name="visible">True</property> <property name="visible">True</property>
@@ -497,6 +514,13 @@ THE SOFTWARE.</property>
<attribute name="weight" value="semibold"/> <attribute name="weight" value="semibold"/>
</attributes> </attributes>
</object> </object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
@@ -855,6 +879,22 @@ THE SOFTWARE.</property>
<property name="margin_top">5</property> <property name="margin_top">5</property>
<property name="margin_bottom">5</property> <property name="margin_bottom">5</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<child>
<object class="GtkBox" id="box33">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImage" id="image14">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixbuf">share/drill32.png</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child> <child>
<object class="GtkLabel" id="label10"> <object class="GtkLabel" id="label10">
<property name="visible">True</property> <property name="visible">True</property>
@@ -865,6 +905,13 @@ THE SOFTWARE.</property>
<attribute name="weight" value="semibold"/> <attribute name="weight" value="semibold"/>
</attributes> </attributes>
</object> </object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
@@ -1359,6 +1406,22 @@ THE SOFTWARE.</property>
<property name="margin_top">5</property> <property name="margin_top">5</property>
<property name="margin_bottom">5</property> <property name="margin_bottom">5</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<child>
<object class="GtkBox" id="box32">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImage" id="image13">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixbuf">share/geometry32.png</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child> <child>
<object class="GtkLabel" id="label15"> <object class="GtkLabel" id="label15">
<property name="visible">True</property> <property name="visible">True</property>
@@ -1369,6 +1432,13 @@ THE SOFTWARE.</property>
<attribute name="weight" value="semibold"/> <attribute name="weight" value="semibold"/>
</attributes> </attributes>
</object> </object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
@@ -1969,6 +2039,22 @@ THE SOFTWARE.</property>
<property name="margin_top">5</property> <property name="margin_top">5</property>
<property name="margin_bottom">5</property> <property name="margin_bottom">5</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<child>
<object class="GtkBox" id="box31">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImage" id="image12">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixbuf">share/flatcam_icon32.png</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child> <child>
<object class="GtkLabel" id="label7"> <object class="GtkLabel" id="label7">
<property name="visible">True</property> <property name="visible">True</property>
@@ -1979,6 +2065,13 @@ THE SOFTWARE.</property>
<attribute name="weight" value="semibold"/> <attribute name="weight" value="semibold"/>
</attributes> </attributes>
</object> </object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
@@ -2786,6 +2879,7 @@ this object.</property>
<object class="GtkMenuBar" id="menubar1"> <object class="GtkMenuBar" id="menubar1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<signal name="deactivate" handler="do_nothing" swapped="no"/>
<child> <child>
<object class="GtkMenuItem" id="menuitem1"> <object class="GtkMenuItem" id="menuitem1">
<property name="visible">True</property> <property name="visible">True</property>
@@ -3103,102 +3197,6 @@ to application defaults.</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="toolbar_style">icons</property> <property name="toolbar_style">icons</property>
<child>
<object class="GtkToolButton" id="zoomfit_toolbutton">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_markup" translatable="yes">Zoom Fit.
(Click on plot and hit &lt;b&gt;1&lt;/b&gt;)</property>
<property name="label" translatable="yes">Fit</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-zoom-100</property>
<signal name="clicked" handler="on_zoom_fit" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="zoomin_toolbutton">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_markup" translatable="yes">Zoom in.
(Click on plot and hit &lt;b&gt;3&lt;/b&gt;
to zoom around a point)</property>
<property name="label" translatable="yes">Zoom+</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-zoom-in</property>
<signal name="clicked" handler="on_zoom_in" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="zoomout_toolbutton">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_markup" translatable="yes">Zoom Out.
(Click on plot and hit &lt;b&gt;2&lt;/b&gt;
to zoom around a point)</property>
<property name="label" translatable="yes">Zoom-</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-zoom-out</property>
<signal name="clicked" handler="on_zoom_out" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="Clear">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_markup" translatable="yes">Clear Plot</property>
<property name="label" translatable="yes">Clear Plots</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-stop</property>
<signal name="clicked" handler="on_clear_plots" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="toolbutton1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_markup" translatable="yes">Re-plot all</property>
<property name="label" translatable="yes">Re-plot</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-redo</property>
<signal name="clicked" handler="on_toolbar_replot" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="toolbutton2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_markup" translatable="yes">Delete selected
object.</property>
<property name="label" translatable="yes">Delete Object</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-delete</property>
<signal name="clicked" handler="on_delete" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@@ -3299,10 +3297,27 @@ for the current object.</property>
<property name="margin_bottom">5</property> <property name="margin_bottom">5</property>
<property name="vexpand">True</property> <property name="vexpand">True</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<child>
<object class="GtkBox" id="box30">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImage" id="image11">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixbuf">share/gear32.png</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child> <child>
<object class="GtkComboBoxText" id="combo_options"> <object class="GtkComboBoxText" id="combo_options">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="has_tooltip">True</property>
<property name="tooltip_markup" translatable="yes">Application defaults get transfered <property name="tooltip_markup" translatable="yes">Application defaults get transfered
to every new project. Project options to every new project. Project options
get inherited by new project objects. get inherited by new project objects.
@@ -3310,6 +3325,15 @@ get inherited by new project objects.
&lt;b&gt;Save&lt;/b&gt; application defaults &lt;b&gt;Save&lt;/b&gt; application defaults
by choosing &lt;i&gt;File + Save defaults&lt;/i&gt;. by choosing &lt;i&gt;File + Save defaults&lt;/i&gt;.
Project obtions are saved with the
project.</property>
<property name="tooltip_text" translatable="yes">Application defaults get transfered
to every new project. Project options
get inherited by new project objects.
Save application defaults
by choosing File + Save defaults.
Project obtions are saved with the Project obtions are saved with the
project.</property> project.</property>
<property name="margin_left">10</property> <property name="margin_left">10</property>
@@ -3324,6 +3348,13 @@ project.</property>
</items> </items>
<signal name="changed" handler="on_options_combo_change" swapped="no"/> <signal name="changed" handler="on_options_combo_change" swapped="no"/>
</object> </object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
@@ -3407,21 +3438,24 @@ project.</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkLabel" id="label55"> <object class="GtkFrame" id="frame2">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="ypad">3</property> <property name="margin_top">8</property>
<property name="label" translatable="yes">Gerber Object</property> <property name="label_xalign">0</property>
<attributes> <child>
<attribute name="weight" value="semibold"/> <object class="GtkAlignment" id="alignment2">
</attributes> <property name="visible">True</property>
</object> <property name="can_focus">False</property>
<packing> <property name="top_padding">6</property>
<property name="expand">False</property> <property name="bottom_padding">6</property>
<property name="fill">True</property> <property name="left_padding">12</property>
<property name="position">4</property> <property name="right_padding">6</property>
</packing> <child>
</child> <object class="GtkBox" id="box34">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child> <child>
<object class="GtkLabel" id="label56"> <object class="GtkLabel" id="label56">
<property name="visible">True</property> <property name="visible">True</property>
@@ -3437,7 +3471,7 @@ project.</property>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">5</property> <property name="position">0</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -3454,7 +3488,7 @@ project.</property>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">6</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -3471,7 +3505,7 @@ project.</property>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">7</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -3487,7 +3521,7 @@ project.</property>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">8</property> <property name="position">3</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -3503,7 +3537,7 @@ project.</property>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">9</property> <property name="position">4</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -3521,7 +3555,7 @@ project.</property>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">10</property> <property name="position">5</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -3534,8 +3568,12 @@ project.</property>
<object class="GtkLabel" id="label58"> <object class="GtkLabel" id="label58">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="has_tooltip">True</property>
<property name="tooltip_markup" translatable="yes">Tool paths for isolation routing are drawn <property name="tooltip_markup" translatable="yes">Tool paths for isolation routing are drawn
at 1/2 of the tool diameter away from at 1/2 of the tool diameter away from
polygons defined in Gerber.</property>
<property name="tooltip_text" translatable="yes">Tool paths for isolation routing are drawn
at 1/2 of the tool diameter away from
polygons defined in Gerber.</property> polygons defined in Gerber.</property>
<property name="xalign">1</property> <property name="xalign">1</property>
<property name="xpad">3</property> <property name="xpad">3</property>
@@ -3570,7 +3608,7 @@ polygons defined in Gerber.</property>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">11</property> <property name="position">6</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -3588,7 +3626,7 @@ polygons defined in Gerber.</property>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">12</property> <property name="position">7</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -3682,6 +3720,7 @@ polygons defined in Gerber.</property>
<property name="receives_default">False</property> <property name="receives_default">False</property>
<property name="margin_right">8</property> <property name="margin_right">8</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
<signal name="toggled" handler="on_options_update" swapped="no"/> <signal name="toggled" handler="on_options_update" swapped="no"/>
</object> </object>
@@ -3699,7 +3738,6 @@ polygons defined in Gerber.</property>
<property name="receives_default">False</property> <property name="receives_default">False</property>
<property name="margin_right">8</property> <property name="margin_right">8</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
<property name="group">rb_app_2tb</property> <property name="group">rb_app_2tb</property>
<signal name="toggled" handler="on_options_update" swapped="no"/> <signal name="toggled" handler="on_options_update" swapped="no"/>
@@ -3738,7 +3776,7 @@ polygons defined in Gerber.</property>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">13</property> <property name="position">8</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -3756,7 +3794,7 @@ polygons defined in Gerber.</property>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">14</property> <property name="position">9</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -3798,7 +3836,7 @@ polygons defined in Gerber.</property>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">15</property> <property name="position">10</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -3816,7 +3854,7 @@ polygons defined in Gerber.</property>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">16</property> <property name="position">11</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -3858,7 +3896,7 @@ polygons defined in Gerber.</property>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">17</property> <property name="position">12</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -3874,25 +3912,63 @@ polygons defined in Gerber.</property>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">18</property> <property name="position">13</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkLabel" id="label67"> <placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label55">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="ypad">3</property> <property name="xpad">5</property>
<property name="label" translatable="yes">Excellon Object</property> <property name="label" translatable="yes">&lt;b&gt;Gerber Objects&lt;/b&gt;</property>
<attributes> <property name="use_markup">True</property>
<attribute name="weight" value="semibold"/> </object>
</attributes> </child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">19</property> <property name="position">4</property>
</packing> </packing>
</child> </child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<object class="GtkFrame" id="frame3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">8</property>
<property name="label_xalign">0</property>
<child>
<object class="GtkAlignment" id="alignment3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="top_padding">6</property>
<property name="bottom_padding">6</property>
<property name="left_padding">12</property>
<property name="right_padding">6</property>
<child>
<object class="GtkBox" id="box36">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child> <child>
<object class="GtkLabel" id="label68"> <object class="GtkLabel" id="label68">
<property name="visible">True</property> <property name="visible">True</property>
@@ -3907,7 +3983,7 @@ polygons defined in Gerber.</property>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">20</property> <property name="position">0</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -3924,7 +4000,7 @@ polygons defined in Gerber.</property>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">21</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -3940,7 +4016,7 @@ polygons defined in Gerber.</property>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">22</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -3956,7 +4032,7 @@ polygons defined in Gerber.</property>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">23</property> <property name="position">3</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -3974,7 +4050,7 @@ polygons defined in Gerber.</property>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">24</property> <property name="position">4</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -4074,25 +4150,54 @@ polygons defined in Gerber.</property>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">25</property> <property name="position">5</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkLabel" id="label74"> <placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label67">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="ypad">3</property> <property name="xpad">4</property>
<property name="label" translatable="yes">Geometry Object</property> <property name="label" translatable="yes">&lt;b&gt;Excellon Objects&lt;/b&gt;</property>
<attributes> <property name="use_markup">True</property>
<attribute name="weight" value="semibold"/> </object>
</attributes> </child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">26</property> <property name="position">7</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkFrame" id="frame4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">8</property>
<property name="label_xalign">0</property>
<child>
<object class="GtkAlignment" id="alignment4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="top_padding">6</property>
<property name="bottom_padding">6</property>
<property name="left_padding">12</property>
<property name="right_padding">6</property>
<child>
<object class="GtkBox" id="box37">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child> <child>
<object class="GtkLabel" id="label73"> <object class="GtkLabel" id="label73">
<property name="visible">True</property> <property name="visible">True</property>
@@ -4107,7 +4212,7 @@ polygons defined in Gerber.</property>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">27</property> <property name="position">0</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -4124,7 +4229,7 @@ polygons defined in Gerber.</property>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">28</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -4140,7 +4245,7 @@ polygons defined in Gerber.</property>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">29</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -4156,7 +4261,7 @@ polygons defined in Gerber.</property>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">30</property> <property name="position">3</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -4174,7 +4279,7 @@ polygons defined in Gerber.</property>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">31</property> <property name="position">4</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -4303,7 +4408,7 @@ polygons defined in Gerber.</property>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">32</property> <property name="position">5</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -4321,7 +4426,7 @@ polygons defined in Gerber.</property>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">33</property> <property name="position">6</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -4421,25 +4526,52 @@ polygons defined in Gerber.</property>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">34</property> <property name="position">7</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkLabel" id="label43"> <placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label99">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="ypad">3</property> <property name="xpad">4</property>
<property name="label" translatable="yes">CNC Job Object</property> <property name="label" translatable="yes">&lt;b&gt;Geometry Objects&lt;/b&gt;</property>
<attributes> <property name="use_markup">True</property>
<attribute name="weight" value="semibold"/> </object>
</attributes> </child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">35</property> <property name="position">8</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkFrame" id="frame5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">8</property>
<property name="label_xalign">0</property>
<child>
<object class="GtkAlignment" id="alignment5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="left_padding">12</property>
<property name="right_padding">6</property>
<child>
<object class="GtkBox" id="box38">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child> <child>
<object class="GtkCheckButton" id="cb_app_cncjob_plot"> <object class="GtkCheckButton" id="cb_app_cncjob_plot">
<property name="label" translatable="yes">Plot</property> <property name="label" translatable="yes">Plot</property>
@@ -4454,15 +4586,9 @@ polygons defined in Gerber.</property>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">36</property> <property name="position">0</property>
</packing> </packing>
</child> </child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child> <child>
<object class="GtkBox" id="box17"> <object class="GtkBox" id="box17">
<property name="visible">True</property> <property name="visible">True</property>
@@ -4501,7 +4627,7 @@ polygons defined in Gerber.</property>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">39</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -4510,6 +4636,40 @@ polygons defined in Gerber.</property>
<child> <child>
<placeholder/> <placeholder/>
</child> </child>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label74">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">&lt;b&gt;CNC Job Objects&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">9</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object> </object>
</child> </child>
</object> </object>

View File

@@ -376,7 +376,7 @@ class Gerber (Geometry):
:rtype : None :rtype : None
""" """
# Apertures # Apertures
print "Scaling apertures..." #print "Scaling apertures..."
for apid in self.apertures: for apid in self.apertures:
for param in self.apertures[apid]: for param in self.apertures[apid]:
if param != "type": # All others are dimensions. if param != "type": # All others are dimensions.
@@ -384,20 +384,20 @@ class Gerber (Geometry):
self.apertures[apid][param] *= factor self.apertures[apid][param] *= factor
# Paths # Paths
print "Scaling paths..." #print "Scaling paths..."
for path in self.paths: for path in self.paths:
path['linestring'] = affinity.scale(path['linestring'], path['linestring'] = affinity.scale(path['linestring'],
factor, factor, origin=(0, 0)) factor, factor, origin=(0, 0))
# Flashes # Flashes
print "Scaling flashes..." #print "Scaling flashes..."
for fl in self.flashes: for fl in self.flashes:
# TODO: Shouldn't 'loc' be a numpy.array()? # TODO: Shouldn't 'loc' be a numpy.array()?
fl['loc'][0] *= factor fl['loc'][0] *= factor
fl['loc'][1] *= factor fl['loc'][1] *= factor
# Regions # Regions
print "Scaling regions..." #print "Scaling regions..."
for reg in self.regions: for reg in self.regions:
reg['polygon'] = affinity.scale(reg['polygon'], factor, factor, reg['polygon'] = affinity.scale(reg['polygon'], factor, factor,
origin=(0, 0)) origin=(0, 0))
@@ -424,20 +424,20 @@ class Gerber (Geometry):
dx, dy = vect dx, dy = vect
# Paths # Paths
print "Shifting paths..." #print "Shifting paths..."
for path in self.paths: for path in self.paths:
path['linestring'] = affinity.translate(path['linestring'], path['linestring'] = affinity.translate(path['linestring'],
xoff=dx, yoff=dy) xoff=dx, yoff=dy)
# Flashes # Flashes
print "Shifting flashes..." #print "Shifting flashes..."
for fl in self.flashes: for fl in self.flashes:
# TODO: Shouldn't 'loc' be a numpy.array()? # TODO: Shouldn't 'loc' be a numpy.array()?
fl['loc'][0] += dx fl['loc'][0] += dx
fl['loc'][1] += dy fl['loc'][1] += dy
# Regions # Regions
print "Shifting regions..." #print "Shifting regions..."
for reg in self.regions: for reg in self.regions:
reg['polygon'] = affinity.translate(reg['polygon'], reg['polygon'] = affinity.translate(reg['polygon'],
xoff=dx, yoff=dy) xoff=dx, yoff=dy)
@@ -808,15 +808,12 @@ class Gerber (Geometry):
:return: None :return: None
""" """
# if len(self.buffered_paths) == 0:
# self.buffer_paths()
print "... buffer_paths()"
self.buffer_paths() self.buffer_paths()
print "... fix_regions()"
self.fix_regions() self.fix_regions()
print "... do_flashes()"
self.do_flashes() self.do_flashes()
print "... cascaded_union()"
self.solid_geometry = cascaded_union(self.buffered_paths + self.solid_geometry = cascaded_union(self.buffered_paths +
[poly['polygon'] for poly in self.regions] + [poly['polygon'] for poly in self.regions] +
self.flash_geometry) self.flash_geometry)
@@ -930,8 +927,10 @@ class Excellon(Geometry):
self.meas_re = re.compile(r'^M7([12])$') self.meas_re = re.compile(r'^M7([12])$')
# Coordinates # Coordinates
self.xcoord_re = re.compile(r'^X(\d*\.?\d*)(?:Y\d*\.?\d*)?$') #self.xcoord_re = re.compile(r'^X(\d*\.?\d*)(?:Y\d*\.?\d*)?$')
self.ycoord_re = re.compile(r'^(?:X\d*\.?\d*)?Y(\d*\.?\d*)$') #self.ycoord_re = re.compile(r'^(?:X\d*\.?\d*)?Y(\d*\.?\d*)$')
self.coordsperiod_re = re.compile(r'(?=.*X(\d*\.\d*))?(?=.*Y(\d*\.\d*))?[XY]')
self.coordsnoperiod_re = re.compile(r'(?!.*\.)(?=.*X(\d*))?(?=.*Y(\d*))?[XY]')
# R - Repeat hole (# times, X offset, Y offset) # R - Repeat hole (# times, X offset, Y offset)
self.rep_re = re.compile(r'^R(\d+)(?=.*[XY])+(?:X(\d*\.?\d*))?(?:Y(\d*\.?\d*))?$') self.rep_re = re.compile(r'^R(\d+)(?=.*[XY])+(?:X(\d*\.?\d*))?(?:Y(\d*\.?\d*))?$')
@@ -962,10 +961,15 @@ class Excellon(Geometry):
:return: None :return: None
""" """
# State variables
current_tool = "" current_tool = ""
in_header = False in_header = False
current_x = None
current_y = None
i = 0 # Line number
for eline in elines: for eline in elines:
i += 1
## Header Begin/End ## ## Header Begin/End ##
if self.hbegin_re.search(eline): if self.hbegin_re.search(eline):
@@ -985,12 +989,46 @@ class Excellon(Geometry):
current_tool = str(int(match.group(1))) current_tool = str(int(match.group(1)))
continue continue
## Drill ## ## Coordinates without period ##
indexx = eline.find("X") match = self.coordsnoperiod_re.search(eline)
indexy = eline.find("Y") if match:
if indexx != -1 and indexy != -1: try:
x = float(int(eline[indexx+1:indexy])/10000.0) x = float(match.group(1))/10000
y = float(int(eline[indexy+1:-1])/10000.0) current_x = x
except TypeError:
x = current_x
try:
y = float(match.group(2))/10000
current_y = y
except TypeError:
y = current_y
if x is None or y is None:
print "ERROR: Missing coordinates"
continue
self.drills.append({'point': Point((x, y)), 'tool': current_tool})
continue
## Coordinates with period ##
match = self.coordsperiod_re.search(eline)
if match:
try:
x = float(match.group(1))
current_x = x
except TypeError:
x = current_x
try:
y = float(match.group(2))
except TypeError:
y = current_y
if x is None or y is None:
print "ERROR: Missing coordinates"
continue
self.drills.append({'point': Point((x, y)), 'tool': current_tool}) self.drills.append({'point': Point((x, y)), 'tool': current_tool})
continue continue