- TclCommand Geocutout is now creating a new geometry object when working on a geometry, preserving also the origin object

This commit is contained in:
Marius Stanciu 2019-06-03 04:47:29 +03:00
parent c409df0a8e
commit 2a30101bb0
6 changed files with 110 additions and 72 deletions

View File

@ -8278,11 +8278,14 @@ The normal flow when working in FlatCAM is the following:</span></p>
self.inform.emit(_("[success] All plots enabled."))
def on_enable_sel_plots(self):
log.debug("App.on_enable_sel_plot()")
object_list = self.collection.get_selected()
self.enable_plots(objects=object_list)
self.inform.emit(_("[success] Selected plots enabled..."))
def on_disable_sel_plots(self):
log.debug("App.on_disable_sel_plot()")
# self.inform.emit(_("Disabling plots ..."))
object_list = self.collection.get_selected()
self.disable_plots(objects=object_list)
@ -8297,14 +8300,9 @@ The normal flow when working in FlatCAM is the following:</span></p>
log.debug("Enabling plots ...")
def worker_task(app_obj):
# app_obj.inform.emit(_("Enabling plots ..."))
for obj in objects:
obj.options['plot'] = True
self.plots_updated.emit()
# Send to worker
self.worker_task.emit({'fcn': worker_task, 'params': [self]})
for obj in objects:
obj.options['plot'] = True
self.plots_updated.emit()
def disable_plots(self, objects):
"""
@ -8315,14 +8313,9 @@ The normal flow when working in FlatCAM is the following:</span></p>
log.debug("Disabling plots ...")
def worker_task(app_obj):
self.inform.emit(_("Disabling plots ..."))
for obj in objects:
obj.options['plot'] = False
self.plots_updated.emit()
# Send to worker
self.worker_task.emit({'fcn': worker_task, 'params': [self]})
for obj in objects:
obj.options['plot'] = False
self.plots_updated.emit()
def clear_plots(self):

View File

@ -137,7 +137,7 @@ class FlatCAMObj(QtCore.QObject):
if key == 'plot':
self.visible = self.options['plot']
self.optionChanged.emit(key)
# self.optionChanged.emit(key)
def set_ui(self, ui):
self.ui = ui
@ -297,8 +297,6 @@ class FlatCAMObj(QtCore.QObject):
return False
self.clear()
return True
def serialize(self):
@ -346,7 +344,7 @@ class FlatCAMObj(QtCore.QObject):
# Not all object types has annotations
try:
self.annotation.visible = value
except AttributeError:
except Exception as e:
pass
@property
@ -366,12 +364,6 @@ class FlatCAMObj(QtCore.QObject):
except AttributeError:
pass
# Not all object types have mark_shapes
# try:
# self.mark_shapes.clear(update)
# except AttributeError:
# pass
def delete(self):
# Free resources
del self.ui
@ -1054,7 +1046,6 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
:param kwargs: color and face_color
:return:
"""
FlatCAMApp.App.log.debug(str(inspect.stack()[1][3]) + " --> FlatCAMGerber.plot()")
# Does all the required setup and returns False
@ -1066,6 +1057,7 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
color = kwargs['color']
else:
color = self.app.defaults['global_plot_line']
if 'face_color' in kwargs:
face_color = kwargs['face_color']
else:
@ -1079,7 +1071,7 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
# Make sure geometry is iterable.
try:
_ = iter(geometry)
__ = iter(geometry)
except TypeError:
geometry = [geometry]
@ -2796,7 +2788,7 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
# this stays for compatibility reasons, in case we try to open old projects
try:
_ = iter(self.solid_geometry)
__ = iter(self.solid_geometry)
except TypeError:
self.solid_geometry = [self.solid_geometry]

View File

@ -9,6 +9,10 @@ CAD program, and create G-Code for Isolation routing.
=================================================
3.06.2019
- TclCommand Geocutout is now creating a new geometry object when working on a geometry, preserving also the origin object
2.06.2019
- fixed issue with geometry name not being updated immediately after change while doing geocutout TclCommand

View File

@ -7294,7 +7294,7 @@ def dict2obj(d):
# def plotg(geo, solid_poly=False, color="black"):
# try:
# _ = iter(geo)
# __ = iter(geo)
# except:
# geo = [geo]
#
@ -7327,7 +7327,7 @@ def dict2obj(d):
# continue
#
# try:
# _ = iter(g)
# __ = iter(g)
# plotg(g, color=color)
# except:
# log.error("Cannot plot: " + str(type(g)))
@ -7633,7 +7633,7 @@ def parse_gerber_number(strnumber, int_digits, frac_digits, zeros):
def autolist(obj):
try:
_ = iter(obj)
__ = iter(obj)
return obj
except TypeError:
return [obj]

View File

@ -415,7 +415,7 @@ class CutOut(FlatCAMTool):
object_geo = cutout_obj.solid_geometry
try:
_ = iter(object_geo)
__ = iter(object_geo)
except TypeError:
object_geo = [object_geo]
@ -565,7 +565,7 @@ class CutOut(FlatCAMTool):
object_geo = cutout_obj.solid_geometry
try:
_ = iter(object_geo)
__ = iter(object_geo)
except TypeError:
object_geo = [object_geo]

View File

@ -179,49 +179,97 @@ class TclCommandGeoCutout(TclCommandSignaled):
if isinstance(cutout_obj, FlatCAMGeometry):
# rename the obj name so it can be identified as cutout
cutout_obj.options["name"] += "_cutout"
# cutout_obj.options["name"] += "_cutout"
if gaps_u == 8 or gaps_u == '2lr':
subtract_rectangle(cutout_obj,
xmin - gapsize, # botleft_x
py - gapsize + lenghty / 4, # botleft_y
xmax + gapsize, # topright_x
py + gapsize + lenghty / 4) # topright_y
subtract_rectangle(cutout_obj,
xmin - gapsize,
py - gapsize - lenghty / 4,
xmax + gapsize,
py + gapsize - lenghty / 4)
# if gaps_u == 8 or gaps_u == '2lr':
# subtract_rectangle(cutout_obj,
# xmin - gapsize, # botleft_x
# py - gapsize + lenghty / 4, # botleft_y
# xmax + gapsize, # topright_x
# py + gapsize + lenghty / 4) # topright_y
# subtract_rectangle(cutout_obj,
# xmin - gapsize,
# py - gapsize - lenghty / 4,
# xmax + gapsize,
# py + gapsize - lenghty / 4)
#
# if gaps_u == 8 or gaps_u == '2tb':
# subtract_rectangle(cutout_obj,
# px - gapsize + lenghtx / 4,
# ymin - gapsize,
# px + gapsize + lenghtx / 4,
# ymax + gapsize)
# subtract_rectangle(cutout_obj,
# px - gapsize - lenghtx / 4,
# ymin - gapsize,
# px + gapsize - lenghtx / 4,
# ymax + gapsize)
#
# if gaps_u == 4 or gaps_u == 'lr':
# subtract_rectangle(cutout_obj,
# xmin - gapsize,
# py - gapsize,
# xmax + gapsize,
# py + gapsize)
#
# if gaps_u == 4 or gaps_u == 'tb':
# subtract_rectangle(cutout_obj,
# px - gapsize,
# ymin - gapsize,
# px + gapsize,
# ymax + gapsize)
if gaps_u == 8 or gaps_u == '2tb':
subtract_rectangle(cutout_obj,
px - gapsize + lenghtx / 4,
ymin - gapsize,
px + gapsize + lenghtx / 4,
ymax + gapsize)
subtract_rectangle(cutout_obj,
px - gapsize - lenghtx / 4,
ymin - gapsize,
px + gapsize - lenghtx / 4,
ymax + gapsize)
def geo_init(geo_obj, app_obj):
geo = deepcopy(cutout_obj.solid_geometry)
if gaps_u == 4 or gaps_u == 'lr':
subtract_rectangle(cutout_obj,
xmin - gapsize,
py - gapsize,
xmax + gapsize,
py + gapsize)
if gaps_u == 8 or gaps_u == '2lr':
geo = substract_rectangle_geo(geo,
xmin - gapsize, # botleft_x
py - gapsize + lenghty / 4, # botleft_y
xmax + gapsize, # topright_x
py + gapsize + lenghty / 4) # topright_y
geo = substract_rectangle_geo(geo,
xmin - gapsize,
py - gapsize - lenghty / 4,
xmax + gapsize,
py + gapsize - lenghty / 4)
if gaps_u == 4 or gaps_u == 'tb':
subtract_rectangle(cutout_obj,
px - gapsize,
ymin - gapsize,
px + gapsize,
ymax + gapsize)
if gaps_u == 8 or gaps_u == '2tb':
geo = substract_rectangle_geo(geo,
px - gapsize + lenghtx / 4,
ymin - gapsize,
px + gapsize + lenghtx / 4,
ymax + gapsize)
geo = substract_rectangle_geo(geo,
px - gapsize - lenghtx / 4,
ymin - gapsize,
px + gapsize - lenghtx / 4,
ymax + gapsize)
cutout_obj.plot()
self.app.inform.emit("[success] Any-form Cutout operation finished.")
self.app.plots_updated.emit()
if gaps_u == 4 or gaps_u == 'lr':
geo = substract_rectangle_geo(geo,
xmin - gapsize,
py - gapsize,
xmax + gapsize,
py + gapsize)
if gaps_u == 4 or gaps_u == 'tb':
geo = substract_rectangle_geo(geo,
px - gapsize,
ymin - gapsize,
px + gapsize,
ymax + gapsize)
geo_obj.solid_geometry = deepcopy(geo)
app_obj.disable_plots(objects=[cutout_obj])
app_obj.inform.emit("[success] Any-form Cutout operation finished.")
outname = cutout_obj.options["name"] + "_cutout"
self.app.new_object('geometry', outname, geo_init)
# cutout_obj.plot()
# self.app.inform.emit("[success] Any-form Cutout operation finished.")
# self.app.plots_updated.emit()
elif isinstance(cutout_obj, FlatCAMGerber):
def geo_init(geo_obj, app_obj):
@ -269,6 +317,7 @@ class TclCommandGeoCutout(TclCommandSignaled):
px + gapsize,
ymax + gapsize)
geo_obj.solid_geometry = deepcopy(geo)
app_obj.inform.emit("[success] Any-form Cutout operation finished.")
outname = cutout_obj.options["name"] + "_cutout"
self.app.new_object('geometry', outname, geo_init)