- some changes in the app.on_togle_units() to make sure we don't try to convert empty parameters which may cause crashes on FlatCAM units change

- updated setup_ubuntu.sh file
- made sure to import certain libraries in some of the FlatCAM files and not to rely on chained imports
This commit is contained in:
Marius Stanciu 2019-07-09 13:58:33 +03:00 committed by Marius
parent 16525a606c
commit 729b7cb11c
6 changed files with 52 additions and 19 deletions

View File

@ -3679,12 +3679,14 @@ class App(QtCore.QObject):
def scale_options(sfactor):
for dim in dimensions:
if dim == 'excellon_toolchangexy':
coords_xy = [float(eval(a)) for a in self.defaults["excellon_toolchangexy"].split(",")]
coordinates = self.defaults["excellon_toolchangexy"].split(",")
coords_xy = [float(eval(a)) for a in coordinates if a != '']
coords_xy[0] *= sfactor
coords_xy[1] *= sfactor
self.options['excellon_toolchangexy'] = "%f, %f" % (coords_xy[0], coords_xy[1])
elif dim == 'geometry_toolchangexy':
coords_xy = [float(eval(a)) for a in self.defaults["geometry_toolchangexy"].split(",")]
coordinates = self.defaults["geometry_toolchangexy"].split(",")
coords_xy = [float(eval(a)) for a in coordinates if a != '']
coords_xy[0] *= sfactor
coords_xy[1] *= sfactor
self.options['geometry_toolchangexy'] = "%f, %f" % (coords_xy[0], coords_xy[1])
@ -3725,38 +3727,48 @@ class App(QtCore.QObject):
sptools[t] *= sfactor
self.options['tools_solderpaste_tools'] += "%f," % sptools[t]
elif dim == 'tools_solderpaste_xy_toolchange':
sp_coords = [float(eval(a)) for a in self.defaults["tools_solderpaste_xy_toolchange"].split(",")]
coordinates = self.defaults["tools_solderpaste_xy_toolchange"].split(",")
sp_coords = [float(eval(a)) for a in coordinates if a != '']
sp_coords[0] *= sfactor
sp_coords[1] *= sfactor
self.options['tools_solderpaste_xy_toolchange'] = "%f, %f" % (sp_coords[0], sp_coords[1])
elif dim == 'global_gridx' or dim == 'global_gridy':
if new_units == 'IN':
val = 0.1
try:
val = float(self.defaults[dim]) * sfactor
self.options[dim] = float('%.6f' % val)
except Exception as e:
log.debug('App.on_toggle_units().scale_defaults() --> %s' % str(e))
self.options[dim] = float('%.6f' % val)
else:
val = 0.1
try:
val = float(self.defaults[dim]) * sfactor
self.options[dim] = float('%.4f' % val)
except Exception as e:
log.debug('App.on_toggle_units().scale_defaults() --> %s' % str(e))
self.options[dim] = float('%.4f' % val)
else:
val = 0.1
try:
self.options[dim] = float(self.options[dim]) * sfactor
val = float(self.options[dim]) * sfactor
except Exception as e:
log.debug('App.on_toggle_units().scale_options() --> %s' % str(e))
self.options[dim] = val
def scale_defaults(sfactor):
for dim in dimensions:
if dim == 'excellon_toolchangexy':
coords_xy = [float(eval(a)) for a in self.defaults["excellon_toolchangexy"].split(",")]
coordinates = self.defaults["excellon_toolchangexy"].split(",")
coords_xy = [float(eval(a)) for a in coordinates if a != '']
coords_xy[0] *= sfactor
coords_xy[1] *= sfactor
self.defaults['excellon_toolchangexy'] = "%.4f, %.4f" % (coords_xy[0], coords_xy[1])
elif dim == 'geometry_toolchangexy':
coords_xy = [float(eval(a)) for a in self.defaults["geometry_toolchangexy"].split(",")]
coordinates = self.defaults["geometry_toolchangexy"].split(",")
coords_xy = [float(eval(a)) for a in coordinates if a != '']
coords_xy[0] *= sfactor
coords_xy[1] *= sfactor
self.defaults['geometry_toolchangexy'] = "%.4f, %.4f" % (coords_xy[0], coords_xy[1])
@ -3797,29 +3809,37 @@ class App(QtCore.QObject):
sptools[t] *= sfactor
self.defaults['tools_solderpaste_tools'] += "%.4f," % sptools[t]
elif dim == 'tools_solderpaste_xy_toolchange':
sp_coords = [float(eval(a)) for a in self.defaults["tools_solderpaste_xy_toolchange"].split(",")]
coordinates = self.defaults["tools_solderpaste_xy_toolchange"].split(",")
sp_coords = [float(eval(a)) for a in coordinates if a != '']
sp_coords[0] *= sfactor
sp_coords[1] *= sfactor
self.defaults['tools_solderpaste_xy_toolchange'] = "%.4f, %.4f" % (sp_coords[0], sp_coords[1])
elif dim == 'global_gridx' or dim == 'global_gridy':
if new_units == 'IN':
val = 0.1
try:
val = float(self.defaults[dim]) * sfactor
self.defaults[dim] = float('%.6f' % val)
except Exception as e:
log.debug('App.on_toggle_units().scale_defaults() --> %s' % str(e))
self.defaults[dim] = float('%.6f' % val)
else:
val = 0.1
try:
val = float(self.defaults[dim]) * sfactor
self.defaults[dim] = float('%.4f' % val)
except Exception as e:
log.debug('App.on_toggle_units().scale_defaults() --> %s' % str(e))
self.defaults[dim] = float('%.4f' % val)
else:
val = 0.1
try:
self.defaults[dim] = float(self.defaults[dim]) * sfactor
val = float(self.defaults[dim]) * sfactor
except Exception as e:
log.debug('App.on_toggle_units().scale_defaults() --> %s' % str(e))
self.defaults[dim] = val
# The scaling factor depending on choice of units.
factor = 1/25.4
if new_units == 'MM':

View File

@ -9,6 +9,12 @@ CAD program, and create G-Code for Isolation routing.
=================================================
9.07.2019
- some changes in the app.on_togle_units() to make sure we don't try to convert empty parameters which may cause crashes on FlatCAM units change
- updated setup_ubuntu.sh file
- made sure to import certain libraries in some of the FlatCAM files and not to rely on chained imports
8.07.2019
- fixed bug that allowed empty tool in the tools generated in Geometry object

View File

@ -2,6 +2,7 @@ from FlatCAMTool import FlatCAMTool
from ObjectCollection import *
from FlatCAMApp import *
from shapely.geometry import box
from shapely.ops import cascaded_union, unary_union
import gettext
import FlatCAMTranslation as fcTranslate

View File

@ -14,7 +14,6 @@ apt-get install python3-tk
apt-get install libspatialindex-dev
apt-get install python3-gdal
apt-get install python3-lxml
easy_install3 -U distribute
pip3 install --upgrade dill
pip3 install --upgrade Shapely
pip3 install --upgrade vispy

View File

@ -1,5 +1,7 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommand
from shapely.ops import cascaded_union
from shapely.geometry import LineString
class TclCommandCutout(TclCommand):
@ -81,11 +83,12 @@ class TclCommandCutout(TclCommand):
try:
obj = self.app.collection.get_by_name(str(name))
except:
except Exception as e:
log.debug("TclCommandCutout.execute() --> %s" % str(e))
return "Could not retrieve object: %s" % name
def geo_init_me(geo_obj, app_obj):
margin = margin_par + dia_par / 2
margin = margin_par + dia_par / 2
gap_size = dia_par + gapsize_par
minx, miny, maxx, maxy = obj.bounds()

View File

@ -1,11 +1,15 @@
from ObjectCollection import *
from tclCommands.TclCommand import TclCommandSignaled
from copy import deepcopy
from shapely.ops import cascaded_union
from shapely.geometry import Polygon, LineString, LinearRing
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.
example:
@ -66,9 +70,9 @@ class TclCommandGeoCutout(TclCommandSignaled):
:return:
"""
def subtract_rectangle(obj_, x0, y0, x1, y1):
pts = [(x0, y0), (x1, y0), (x1, y1), (x0, y1)]
obj_.subtract_polygon(pts)
# def subtract_rectangle(obj_, x0, y0, x1, y1):
# pts = [(x0, y0), (x1, y0), (x1, y1), (x0, y1)]
# obj_.subtract_polygon(pts)
def substract_rectangle_geo(geo, x0, y0, x1, y1):
pts = [(x0, y0), (x1, y0), (x1, y1), (x0, y1)]