- refactored the imports in the Plugins, moved almost all imports in the AppTool file

- fixed a number of issues, mostly leftovers from moving the UI of a Plugin in its own class
- fixed some bugs in the Punch Gerber plugin
- fixed some bugs where the 'pool' parameter was not passed when creating shapes collections (in 3D graphic mode); I wonder how it worked until now
- added a new feature in the Isolation Plugin: now for all the isolation Geometry objects this plugin can do a supplementary simplification of the geometry using the tolerance parameter defined in the General Parameters. This should lead to a reduced number of tool lifts when doing corners
This commit is contained in:
Marius Stanciu
2022-03-31 19:28:19 +03:00
committed by Marius Stanciu
parent e1824a09f7
commit ada48269a9
43 changed files with 378 additions and 797 deletions

View File

@@ -5,33 +5,11 @@
# MIT Licence #
# ##########################################################
from PyQt6 import QtWidgets, QtCore, QtGui
from appTool import AppTool
from appGUI.GUIElements import FCCheckBox, FCDoubleSpinner, RadioSet, FCTable, FCButton,\
FCComboBox, OptionalInputSection, FCLabel, FCInputDialogSpinnerButton, FCComboBox2, \
VerticalScrollArea, FCGridLayout, FCFrame
from appTool import *
from appParsers.ParseGerber import Gerber
from camlib import grace, flatten_shapely_geometry
from copy import deepcopy
import numpy as np
from shapely.geometry import base
from shapely.ops import unary_union, nearest_points
from shapely.geometry import MultiPolygon, Polygon, MultiLineString, LineString, LinearRing
from matplotlib.backend_bases import KeyEvent as mpl_key_event
import logging
import traceback
import sys
import gettext
import simplejson as json
import appTranslation as fcTranslate
import builtins
fcTranslate.apply_language('strings')
if '_' not in builtins.__dict__:
_ = gettext.gettext
@@ -69,6 +47,8 @@ class NonCopperClear(AppTool, Gerber):
# store here the default data for Geometry Data
self.default_data = {}
self.grid_status_memory = None
self.obj_name = ""
self.ncc_obj = None
@@ -809,7 +789,8 @@ class NonCopperClear(AppTool, Gerber):
# make the diameter column editable
for row in range(tool_id):
flags = QtCore.Qt.ItemFlag.ItemIsEditable | QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled
flags = QtCore.Qt.ItemFlag.ItemIsEditable | QtCore.Qt.ItemFlag.ItemIsSelectable | \
QtCore.Qt.ItemFlag.ItemIsEnabled
self.ui.tools_table.item(row, 1).setFlags(flags)
self.ui.tools_table.resizeColumnsToContents()
@@ -1784,7 +1765,7 @@ class NonCopperClear(AppTool, Gerber):
# "%.4f    " % (self.app.dx, self.app.dy))
self.app.ui.update_location_labels(self.app.dx, self.app.dy, curr_pos[0], curr_pos[1])
units = self.app.app_units.lower()
# units = self.app.app_units.lower()
# self.app.plotcanvas.text_hud.text = \
# 'Dx:\t{:<.4f} [{:s}]\nDy:\t{:<.4f} [{:s}]\n\nX: \t{:<.4f} [{:s}]\nY: \t{:<.4f} [{:s}]'.format(
# self.app.dx, units, self.app.dy, units, curr_pos[0], units, curr_pos[1], units)
@@ -1854,14 +1835,6 @@ class NonCopperClear(AppTool, Gerber):
# restore the Grid snapping if it was active before
if self.grid_status_memory is True:
self.app.ui.grid_snap_btn.trigger()
if self.app.use_3d_engine:
self.app.plotcanvas.graph_event_disconnect('mouse_release', self.on_single_poly_mouse_release)
self.app.plotcanvas.graph_event_disconnect('key_press', self.on_key_press)
else:
self.app.plotcanvas.graph_event_disconnect(self.mr)
self.app.plotcanvas.graph_event_disconnect(self.kp)
self.app.tool_shapes.clear(update=True)
except Exception as e:
self.app.log.error("ToolNCC.on_key_press() _2 --> %s" % str(e))
@@ -1919,7 +1892,7 @@ class NonCopperClear(AppTool, Gerber):
box_geo = box_obj.solid_geometry
if box_kind == 'geometry':
box_geo = flatten_shapely_geometry(box_geo)
env_obj = flatten_shapely_geometry(box_geo)
elif box_kind == 'gerber':
box_geo = unary_union(box_obj.solid_geometry).convex_hull
ncc_geo = unary_union(ncc_obj.solid_geometry).convex_hull
@@ -2846,7 +2819,7 @@ class NonCopperClear(AppTool, Gerber):
# Background
self.app.worker_task.emit({'fcn': job_thread, 'params': [self.app]})
else:
job_thread(app_obj=self.app)
job_thread(a_obj=self.app)
def clear_copper_tcl(self, ncc_obj, sel_obj=None, ncctooldia=None, isotooldia=None, margin=None, has_offset=None,
offset=None, select_method=None, outname=None, overlap=None, connect=None, contour=None,
@@ -3890,7 +3863,7 @@ class NonCopperClear(AppTool, Gerber):
def poly2rings(poly):
return [poly.exterior] + [interior for interior in poly.interiors]
def generate_envelope(self, offset, invert, envelope_iso_type=2, follow=None):
def generate_envelope(self, offset, invert, envelope_iso_type=2):
# isolation_geometry produces an envelope that is going on the left of the geometry
# (the copper features). To leave the least amount of burrs on the features
# the tool needs to travel on the right side of the features (this is called conventional milling)
@@ -3898,7 +3871,7 @@ class NonCopperClear(AppTool, Gerber):
# the other passes overlap preceding ones and cut the left over copper. It is better for them
# to cut on the right side of the left over copper i.e on the left side of the features.
try:
geom = self.isolation_geometry(offset, iso_type=envelope_iso_type, follow=follow)
geom = self.isolation_geometry(offset, iso_type=envelope_iso_type)
except Exception as e:
self.app.log.error('NonCopperClear.generate_envelope() --> %s' % str(e))
return 'fail'
@@ -4034,7 +4007,7 @@ class NonCopperClear(AppTool, Gerber):
self.app.tools_db_tab.ui.cancel_tool_from_db.show()
def reset_fields(self):
self.object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
self.ui.object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
class NccUI: