- TclCommand Geocutout is now creating a new geometry object when working on a geometry, preserving also the origin object
This commit is contained in:
parent
c409df0a8e
commit
2a30101bb0
|
@ -8278,11 +8278,14 @@ The normal flow when working in FlatCAM is the following:</span></p>
|
||||||
self.inform.emit(_("[success] All plots enabled."))
|
self.inform.emit(_("[success] All plots enabled."))
|
||||||
|
|
||||||
def on_enable_sel_plots(self):
|
def on_enable_sel_plots(self):
|
||||||
|
log.debug("App.on_enable_sel_plot()")
|
||||||
object_list = self.collection.get_selected()
|
object_list = self.collection.get_selected()
|
||||||
self.enable_plots(objects=object_list)
|
self.enable_plots(objects=object_list)
|
||||||
self.inform.emit(_("[success] Selected plots enabled..."))
|
self.inform.emit(_("[success] Selected plots enabled..."))
|
||||||
|
|
||||||
def on_disable_sel_plots(self):
|
def on_disable_sel_plots(self):
|
||||||
|
log.debug("App.on_disable_sel_plot()")
|
||||||
|
|
||||||
# self.inform.emit(_("Disabling plots ..."))
|
# self.inform.emit(_("Disabling plots ..."))
|
||||||
object_list = self.collection.get_selected()
|
object_list = self.collection.get_selected()
|
||||||
self.disable_plots(objects=object_list)
|
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 ...")
|
log.debug("Enabling plots ...")
|
||||||
|
|
||||||
def worker_task(app_obj):
|
for obj in objects:
|
||||||
# app_obj.inform.emit(_("Enabling plots ..."))
|
obj.options['plot'] = True
|
||||||
for obj in objects:
|
self.plots_updated.emit()
|
||||||
obj.options['plot'] = True
|
|
||||||
self.plots_updated.emit()
|
|
||||||
|
|
||||||
# Send to worker
|
|
||||||
self.worker_task.emit({'fcn': worker_task, 'params': [self]})
|
|
||||||
|
|
||||||
def disable_plots(self, objects):
|
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 ...")
|
log.debug("Disabling plots ...")
|
||||||
|
|
||||||
def worker_task(app_obj):
|
for obj in objects:
|
||||||
self.inform.emit(_("Disabling plots ..."))
|
obj.options['plot'] = False
|
||||||
for obj in objects:
|
self.plots_updated.emit()
|
||||||
obj.options['plot'] = False
|
|
||||||
self.plots_updated.emit()
|
|
||||||
|
|
||||||
# Send to worker
|
|
||||||
self.worker_task.emit({'fcn': worker_task, 'params': [self]})
|
|
||||||
|
|
||||||
def clear_plots(self):
|
def clear_plots(self):
|
||||||
|
|
||||||
|
|
|
@ -137,7 +137,7 @@ class FlatCAMObj(QtCore.QObject):
|
||||||
if key == 'plot':
|
if key == 'plot':
|
||||||
self.visible = self.options['plot']
|
self.visible = self.options['plot']
|
||||||
|
|
||||||
self.optionChanged.emit(key)
|
# self.optionChanged.emit(key)
|
||||||
|
|
||||||
def set_ui(self, ui):
|
def set_ui(self, ui):
|
||||||
self.ui = ui
|
self.ui = ui
|
||||||
|
@ -297,8 +297,6 @@ class FlatCAMObj(QtCore.QObject):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
self.clear()
|
self.clear()
|
||||||
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def serialize(self):
|
def serialize(self):
|
||||||
|
@ -346,7 +344,7 @@ class FlatCAMObj(QtCore.QObject):
|
||||||
# Not all object types has annotations
|
# Not all object types has annotations
|
||||||
try:
|
try:
|
||||||
self.annotation.visible = value
|
self.annotation.visible = value
|
||||||
except AttributeError:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -366,12 +364,6 @@ class FlatCAMObj(QtCore.QObject):
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Not all object types have mark_shapes
|
|
||||||
# try:
|
|
||||||
# self.mark_shapes.clear(update)
|
|
||||||
# except AttributeError:
|
|
||||||
# pass
|
|
||||||
|
|
||||||
def delete(self):
|
def delete(self):
|
||||||
# Free resources
|
# Free resources
|
||||||
del self.ui
|
del self.ui
|
||||||
|
@ -1054,7 +1046,6 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
|
||||||
:param kwargs: color and face_color
|
:param kwargs: color and face_color
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
FlatCAMApp.App.log.debug(str(inspect.stack()[1][3]) + " --> FlatCAMGerber.plot()")
|
FlatCAMApp.App.log.debug(str(inspect.stack()[1][3]) + " --> FlatCAMGerber.plot()")
|
||||||
|
|
||||||
# Does all the required setup and returns False
|
# Does all the required setup and returns False
|
||||||
|
@ -1066,6 +1057,7 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
|
||||||
color = kwargs['color']
|
color = kwargs['color']
|
||||||
else:
|
else:
|
||||||
color = self.app.defaults['global_plot_line']
|
color = self.app.defaults['global_plot_line']
|
||||||
|
|
||||||
if 'face_color' in kwargs:
|
if 'face_color' in kwargs:
|
||||||
face_color = kwargs['face_color']
|
face_color = kwargs['face_color']
|
||||||
else:
|
else:
|
||||||
|
@ -1079,7 +1071,7 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
|
||||||
|
|
||||||
# Make sure geometry is iterable.
|
# Make sure geometry is iterable.
|
||||||
try:
|
try:
|
||||||
_ = iter(geometry)
|
__ = iter(geometry)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
geometry = [geometry]
|
geometry = [geometry]
|
||||||
|
|
||||||
|
@ -2796,7 +2788,7 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
|
||||||
|
|
||||||
# this stays for compatibility reasons, in case we try to open old projects
|
# this stays for compatibility reasons, in case we try to open old projects
|
||||||
try:
|
try:
|
||||||
_ = iter(self.solid_geometry)
|
__ = iter(self.solid_geometry)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
self.solid_geometry = [self.solid_geometry]
|
self.solid_geometry = [self.solid_geometry]
|
||||||
|
|
||||||
|
|
|
@ -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
|
2.06.2019
|
||||||
|
|
||||||
- fixed issue with geometry name not being updated immediately after change while doing geocutout TclCommand
|
- fixed issue with geometry name not being updated immediately after change while doing geocutout TclCommand
|
||||||
|
|
|
@ -7294,7 +7294,7 @@ def dict2obj(d):
|
||||||
|
|
||||||
# def plotg(geo, solid_poly=False, color="black"):
|
# def plotg(geo, solid_poly=False, color="black"):
|
||||||
# try:
|
# try:
|
||||||
# _ = iter(geo)
|
# __ = iter(geo)
|
||||||
# except:
|
# except:
|
||||||
# geo = [geo]
|
# geo = [geo]
|
||||||
#
|
#
|
||||||
|
@ -7327,7 +7327,7 @@ def dict2obj(d):
|
||||||
# continue
|
# continue
|
||||||
#
|
#
|
||||||
# try:
|
# try:
|
||||||
# _ = iter(g)
|
# __ = iter(g)
|
||||||
# plotg(g, color=color)
|
# plotg(g, color=color)
|
||||||
# except:
|
# except:
|
||||||
# log.error("Cannot plot: " + str(type(g)))
|
# log.error("Cannot plot: " + str(type(g)))
|
||||||
|
@ -7633,7 +7633,7 @@ def parse_gerber_number(strnumber, int_digits, frac_digits, zeros):
|
||||||
|
|
||||||
def autolist(obj):
|
def autolist(obj):
|
||||||
try:
|
try:
|
||||||
_ = iter(obj)
|
__ = iter(obj)
|
||||||
return obj
|
return obj
|
||||||
except TypeError:
|
except TypeError:
|
||||||
return [obj]
|
return [obj]
|
||||||
|
|
|
@ -415,7 +415,7 @@ class CutOut(FlatCAMTool):
|
||||||
object_geo = cutout_obj.solid_geometry
|
object_geo = cutout_obj.solid_geometry
|
||||||
|
|
||||||
try:
|
try:
|
||||||
_ = iter(object_geo)
|
__ = iter(object_geo)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
object_geo = [object_geo]
|
object_geo = [object_geo]
|
||||||
|
|
||||||
|
@ -565,7 +565,7 @@ class CutOut(FlatCAMTool):
|
||||||
object_geo = cutout_obj.solid_geometry
|
object_geo = cutout_obj.solid_geometry
|
||||||
|
|
||||||
try:
|
try:
|
||||||
_ = iter(object_geo)
|
__ = iter(object_geo)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
object_geo = [object_geo]
|
object_geo = [object_geo]
|
||||||
|
|
||||||
|
|
|
@ -179,49 +179,97 @@ class TclCommandGeoCutout(TclCommandSignaled):
|
||||||
|
|
||||||
if isinstance(cutout_obj, FlatCAMGeometry):
|
if isinstance(cutout_obj, FlatCAMGeometry):
|
||||||
# rename the obj name so it can be identified as cutout
|
# 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':
|
# if gaps_u == 8 or gaps_u == '2lr':
|
||||||
subtract_rectangle(cutout_obj,
|
# subtract_rectangle(cutout_obj,
|
||||||
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
|
||||||
subtract_rectangle(cutout_obj,
|
# subtract_rectangle(cutout_obj,
|
||||||
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':
|
||||||
|
# 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':
|
def geo_init(geo_obj, app_obj):
|
||||||
subtract_rectangle(cutout_obj,
|
geo = deepcopy(cutout_obj.solid_geometry)
|
||||||
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':
|
if gaps_u == 8 or gaps_u == '2lr':
|
||||||
subtract_rectangle(cutout_obj,
|
geo = substract_rectangle_geo(geo,
|
||||||
xmin - gapsize,
|
xmin - gapsize, # botleft_x
|
||||||
py - gapsize,
|
py - gapsize + lenghty / 4, # botleft_y
|
||||||
xmax + gapsize,
|
xmax + gapsize, # topright_x
|
||||||
py + gapsize)
|
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':
|
if gaps_u == 8 or gaps_u == '2tb':
|
||||||
subtract_rectangle(cutout_obj,
|
geo = substract_rectangle_geo(geo,
|
||||||
px - gapsize,
|
px - gapsize + lenghtx / 4,
|
||||||
ymin - gapsize,
|
ymin - gapsize,
|
||||||
px + gapsize,
|
px + gapsize + lenghtx / 4,
|
||||||
ymax + gapsize)
|
ymax + gapsize)
|
||||||
|
geo = substract_rectangle_geo(geo,
|
||||||
|
px - gapsize - lenghtx / 4,
|
||||||
|
ymin - gapsize,
|
||||||
|
px + gapsize - lenghtx / 4,
|
||||||
|
ymax + gapsize)
|
||||||
|
|
||||||
cutout_obj.plot()
|
if gaps_u == 4 or gaps_u == 'lr':
|
||||||
self.app.inform.emit("[success] Any-form Cutout operation finished.")
|
geo = substract_rectangle_geo(geo,
|
||||||
self.app.plots_updated.emit()
|
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):
|
elif isinstance(cutout_obj, FlatCAMGerber):
|
||||||
|
|
||||||
def geo_init(geo_obj, app_obj):
|
def geo_init(geo_obj, app_obj):
|
||||||
|
@ -269,6 +317,7 @@ class TclCommandGeoCutout(TclCommandSignaled):
|
||||||
px + gapsize,
|
px + gapsize,
|
||||||
ymax + gapsize)
|
ymax + gapsize)
|
||||||
geo_obj.solid_geometry = deepcopy(geo)
|
geo_obj.solid_geometry = deepcopy(geo)
|
||||||
|
app_obj.inform.emit("[success] Any-form Cutout operation finished.")
|
||||||
|
|
||||||
outname = cutout_obj.options["name"] + "_cutout"
|
outname = cutout_obj.options["name"] + "_cutout"
|
||||||
self.app.new_object('geometry', outname, geo_init)
|
self.app.new_object('geometry', outname, geo_init)
|
||||||
|
|
Loading…
Reference in New Issue