- fixed the Circle Steps parameter for both Gerber and Geometry objects not being applied and instead the app internal defaults were used.

- fixed the Tcl command Geocutout issue that gave an error when using the 4 or 8 value for gaps parameter
This commit is contained in:
Marius Stanciu 2019-05-19 17:15:24 +03:00
parent f71645c96c
commit a545658d44
4 changed files with 57 additions and 61 deletions

View File

@ -684,7 +684,7 @@ class App(QtCore.QObject):
"gerber_noncopperrounded": False, "gerber_noncopperrounded": False,
"gerber_bboxmargin": 0.1, "gerber_bboxmargin": 0.1,
"gerber_bboxrounded": False, "gerber_bboxrounded": False,
"gerber_circle_steps": 64, "gerber_circle_steps": 128,
"gerber_use_buffer_for_union": True, "gerber_use_buffer_for_union": True,
# Gerber Advanced Options # Gerber Advanced Options
@ -746,7 +746,7 @@ class App(QtCore.QObject):
# Geometry General # Geometry General
"geometry_plot": True, "geometry_plot": True,
"geometry_circle_steps": 64, "geometry_circle_steps": 128,
"geometry_cnctooldia": 0.016, "geometry_cnctooldia": 0.016,
# Geometry Options # Geometry Options

View File

@ -8,6 +8,10 @@ Among other things, it can take a Gerber file generated by your favorite PCB
CAD program, and create G-Code for Isolation routing. CAD program, and create G-Code for Isolation routing.
================================================= =================================================
19.05.2019
- fixed the Circle Steps parameter for both Gerber and Geometry objects not being applied and instead the app internal defaults were used.
- fixed the Tcl command Geocutout issue that gave an error when using the 4 or 8 value for gaps parameter
18.05.2019 18.05.2019

View File

@ -86,7 +86,7 @@ class Geometry(object):
defaults = { defaults = {
"units": 'in', "units": 'in',
"geo_steps_per_circle": 64 "geo_steps_per_circle": 128
} }
def __init__(self, geo_steps_per_circle=None): def __init__(self, geo_steps_per_circle=None):
@ -1884,10 +1884,10 @@ class Gerber (Geometry):
""" """
defaults = { # defaults = {
"steps_per_circle": 56, # "steps_per_circle": 128,
"use_buffer_for_union": True # "use_buffer_for_union": True
} # }
def __init__(self, steps_per_circle=None): def __init__(self, steps_per_circle=None):
""" """
@ -1899,12 +1899,12 @@ class Gerber (Geometry):
""" """
# How to discretize a circle. # How to discretize a circle.
if steps_per_circle is None: # if steps_per_circle is None:
steps_per_circle = int(Gerber.defaults['steps_per_circle']) # steps_per_circle = int(Gerber.defaults['steps_per_circle'])
self.steps_per_circle = int(steps_per_circle) self.steps_per_circle = int(self.app.defaults["gerber_circle_steps"])
# Initialize parent # Initialize parent
Geometry.__init__(self, geo_steps_per_circle=int(steps_per_circle)) Geometry.__init__(self, geo_steps_per_circle=int(self.app.defaults["gerber_circle_steps"]))
# Number format # Number format
self.int_digits = 3 self.int_digits = 3
@ -2043,7 +2043,7 @@ class Gerber (Geometry):
self.am1_re = re.compile(r'^%AM([^\*]+)\*([^%]+)?(%)?$') self.am1_re = re.compile(r'^%AM([^\*]+)\*([^%]+)?(%)?$')
self.am2_re = re.compile(r'(.*)%$') self.am2_re = re.compile(r'(.*)%$')
self.use_buffer_for_union = self.defaults["use_buffer_for_union"] self.use_buffer_for_union = self.app.defaults["gerber_use_buffer_for_union"]
def aperture_parse(self, apertureId, apertureType, apParameters): def aperture_parse(self, apertureId, apertureType, apParameters):
""" """
@ -2455,9 +2455,9 @@ class Gerber (Geometry):
log.debug("Bare op-code %d." % current_operation_code) log.debug("Bare op-code %d." % current_operation_code)
geo_dict = dict() geo_dict = dict()
flash = Gerber.create_flash_geometry( flash = self.create_flash_geometry(
Point(current_x, current_y), self.apertures[current_aperture], Point(current_x, current_y), self.apertures[current_aperture],
int(self.steps_per_circle)) self.steps_per_circle)
geo_dict['follow'] = Point([current_x, current_y]) geo_dict['follow'] = Point([current_x, current_y])
@ -2870,10 +2870,10 @@ class Gerber (Geometry):
geo_dict['follow'] = geo_flash geo_dict['follow'] = geo_flash
# this treats the case when we are storing geometry as solids # this treats the case when we are storing geometry as solids
flash = Gerber.create_flash_geometry( flash = self.create_flash_geometry(
Point( [linear_x, linear_y]), Point( [linear_x, linear_y]),
self.apertures[current_aperture], self.apertures[current_aperture],
int(self.steps_per_circle) self.steps_per_circle
) )
if not flash.is_empty: if not flash.is_empty:
poly_buffer.append(flash) poly_buffer.append(flash)
@ -3011,7 +3011,7 @@ class Gerber (Geometry):
this_arc = arc(center, radius, start, stop, this_arc = arc(center, radius, start, stop,
arcdir[current_interpolation_mode], arcdir[current_interpolation_mode],
int(self.steps_per_circle)) self.steps_per_circle)
# The last point in the computed arc can have # The last point in the computed arc can have
# numerical errors. The exact final point is the # numerical errors. The exact final point is the
@ -3065,7 +3065,7 @@ class Gerber (Geometry):
log.debug("########## ACCEPTING ARC ############") log.debug("########## ACCEPTING ARC ############")
this_arc = arc(center, radius, start, stop, this_arc = arc(center, radius, start, stop,
arcdir[current_interpolation_mode], arcdir[current_interpolation_mode],
int(self.steps_per_circle)) self.steps_per_circle)
# Replace with exact values # Replace with exact values
this_arc[-1] = (circular_x, circular_y) this_arc[-1] = (circular_x, circular_y)
@ -3132,7 +3132,6 @@ class Gerber (Geometry):
conversion_factor = 25.4 if file_units == 'IN' else (1/25.4) if file_units != app_units else 1 conversion_factor = 25.4 if file_units == 'IN' else (1/25.4) if file_units != app_units else 1
# --- Apply buffer --- # --- Apply buffer ---
# this treats the case when we are storing geometry as paths # this treats the case when we are storing geometry as paths
self.follow_geometry = follow_buffer self.follow_geometry = follow_buffer
@ -3175,9 +3174,6 @@ class Gerber (Geometry):
# log.debug('Flashing @%s, Aperture: %s' % (location, aperture)) # log.debug('Flashing @%s, Aperture: %s' % (location, aperture))
if steps_per_circle is None:
steps_per_circle = 64
if type(location) == list: if type(location) == list:
location = Point(location) location = Point(location)

View File

@ -2,6 +2,7 @@ from ObjectCollection import *
from tclCommands.TclCommand import TclCommandSignaled from tclCommands.TclCommand import TclCommandSignaled
from copy import deepcopy from copy import deepcopy
class TclCommandGeoCutout(TclCommandSignaled): class TclCommandGeoCutout(TclCommandSignaled):
""" """
Tcl shell command to create a board cutout geometry. Allow cutout for any shape. Cuts holding gaps from geometry. Tcl shell command to create a board cutout geometry. Allow cutout for any shape. Cuts holding gaps from geometry.
@ -65,7 +66,6 @@ class TclCommandGeoCutout(TclCommandSignaled):
:return: :return:
""" """
def subtract_rectangle(obj_, x0, y0, x1, y1): def subtract_rectangle(obj_, x0, y0, x1, y1):
pts = [(x0, y0), (x1, y0), (x1, y1), (x0, y1)] pts = [(x0, y0), (x1, y0), (x1, y1), (x0, y1)]
obj_.subtract_polygon(pts) obj_.subtract_polygon(pts)
@ -73,7 +73,6 @@ class TclCommandGeoCutout(TclCommandSignaled):
def substract_rectangle_geo(geo, x0, y0, x1, y1): def substract_rectangle_geo(geo, x0, y0, x1, y1):
pts = [(x0, y0), (x1, y0), (x1, y1), (x0, y1)] pts = [(x0, y0), (x1, y0), (x1, y1), (x0, y1)]
def flatten(geometry=None, reset=True, pathonly=False): def flatten(geometry=None, reset=True, pathonly=False):
""" """
Creates a list of non-iterable linear geometry objects. Creates a list of non-iterable linear geometry objects.
@ -89,15 +88,15 @@ class TclCommandGeoCutout(TclCommandSignaled):
if reset: if reset:
self.flat_geometry = [] self.flat_geometry = []
## If iterable, expand recursively. # If iterable, expand recursively.
try: try:
for geo in geometry: for geo_el in geometry:
if geo is not None: if geo_el is not None:
flatten(geometry=geo, flatten(geometry=geo_el,
reset=False, reset=False,
pathonly=pathonly) pathonly=pathonly)
## Not iterable, do the actual indexing and add. # Not iterable, do the actual indexing and add.
except TypeError: except TypeError:
if pathonly and type(geometry) == Polygon: if pathonly and type(geometry) == Polygon:
self.flat_geometry.append(geometry.exterior) self.flat_geometry.append(geometry.exterior)
@ -151,14 +150,15 @@ class TclCommandGeoCutout(TclCommandSignaled):
# Get source object. # Get source object.
try: try:
cutout_obj = self.app.collection.get_by_name(str(name)) cutout_obj = self.app.collection.get_by_name(str(name))
except: except Exception as e:
log.debug("TclCommandGeoCutout --> %s" % str(e))
return "Could not retrieve object: %s" % name return "Could not retrieve object: %s" % name
if 0 in {dia}: if 0 in {dia}:
self.app.inform.emit("[WARNING]Tool Diameter is zero value. Change it to a positive real number.") self.app.inform.emit("[WARNING]Tool Diameter is zero value. Change it to a positive real number.")
return "Tool Diameter is zero value. Change it to a positive real number." return "Tool Diameter is zero value. Change it to a positive real number."
if gaps not in ['lr', 'tb', '2lr', '2tb', 4, 8]: if gaps not in ['lr', 'tb', '2lr', '2tb', '4', '8']:
self.app.inform.emit("[WARNING]Gaps value can be only one of: 'lr', 'tb', '2lr', '2tb', 4 or 8. " self.app.inform.emit("[WARNING]Gaps value can be only one of: 'lr', 'tb', '2lr', '2tb', 4 or 8. "
"Fill in a correct value and retry. ") "Fill in a correct value and retry. ")
return return
@ -226,47 +226,47 @@ class TclCommandGeoCutout(TclCommandSignaled):
def geo_init(geo_obj, app_obj): def geo_init(geo_obj, app_obj):
try: try:
geo = cutout_obj.isolation_geometry((dia / 2), iso_type=0, corner=2, follow=None) geo = cutout_obj.isolation_geometry((dia / 2), iso_type=0, corner=2, follow=None)
except Exception as e: except Exception as exc:
log.debug("TclCommandGeoCutout.execute() --> %s" % str(e)) log.debug("TclCommandGeoCutout.execute() --> %s" % str(exc))
return 'fail' return 'fail'
if gaps_u == 8 or gaps_u == '2lr': if gaps_u == 8 or gaps_u == '2lr':
geo = substract_rectangle_geo(geo, geo = substract_rectangle_geo(geo,
xmin - gapsize, # botleft_x xmin - gapsize, # botleft_x
py - gapsize + lenghty / 4, # botleft_y py - gapsize + lenghty / 4, # botleft_y
xmax + gapsize, # topright_x xmax + gapsize, # topright_x
py + gapsize + lenghty / 4) # topright_y py + gapsize + lenghty / 4) # topright_y
geo = substract_rectangle_geo(geo, geo = substract_rectangle_geo(geo,
xmin - gapsize, xmin - gapsize,
py - gapsize - lenghty / 4, py - gapsize - lenghty / 4,
xmax + gapsize, xmax + gapsize,
py + gapsize - lenghty / 4) py + gapsize - lenghty / 4)
if gaps_u == 8 or gaps_u == '2tb': if gaps_u == 8 or gaps_u == '2tb':
geo = substract_rectangle_geo(geo, geo = substract_rectangle_geo(geo,
px - gapsize + lenghtx / 4, px - gapsize + lenghtx / 4,
ymin - gapsize, ymin - gapsize,
px + gapsize + lenghtx / 4, px + gapsize + lenghtx / 4,
ymax + gapsize) ymax + gapsize)
geo = substract_rectangle_geo(geo, geo = substract_rectangle_geo(geo,
px - gapsize - lenghtx / 4, px - gapsize - lenghtx / 4,
ymin - gapsize, ymin - gapsize,
px + gapsize - lenghtx / 4, px + gapsize - lenghtx / 4,
ymax + gapsize) ymax + gapsize)
if gaps_u == 4 or gaps_u == 'lr': if gaps_u == 4 or gaps_u == 'lr':
geo = substract_rectangle_geo(geo, geo = substract_rectangle_geo(geo,
xmin - gapsize, xmin - gapsize,
py - gapsize, py - gapsize,
xmax + gapsize, xmax + gapsize,
py + gapsize) py + gapsize)
if gaps_u == 4 or gaps_u == 'tb': if gaps_u == 4 or gaps_u == 'tb':
geo = substract_rectangle_geo(geo, geo = substract_rectangle_geo(geo,
px - gapsize, px - gapsize,
ymin - gapsize, ymin - gapsize,
px + gapsize, px + gapsize,
ymax + gapsize) ymax + gapsize)
geo_obj.solid_geometry = geo geo_obj.solid_geometry = geo
outname = cutout_obj.options["name"] + "_cutout" outname = cutout_obj.options["name"] + "_cutout"
@ -276,7 +276,3 @@ class TclCommandGeoCutout(TclCommandSignaled):
else: else:
self.app.inform.emit("[ERROR]Cancelled. Object type is not supported.") self.app.inform.emit("[ERROR]Cancelled. Object type is not supported.")
return return