- 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,12 @@
# MIT Licence #
# ##########################################################
from PyQt6 import QtWidgets, QtGui, QtCore
from PyQt6.QtCore import Qt
from appTool import AppTool
from copy import deepcopy
from appTool import *
from appParsers.ParseGerber import Gerber
from camlib import Geometry, AppRTreeStorage, grace
from appGUI.GUIElements import FCTable, FCDoubleSpinner, FCCheckBox, FCInputDoubleSpinner, RadioSet, \
FCButton, FCComboBox, FCLabel, FCComboBox2, VerticalScrollArea, FCGridLayout, FCFrame
from shapely.geometry import base, Polygon, MultiPolygon, LinearRing, Point, MultiLineString, LineString
from shapely.ops import unary_union, linemerge
from matplotlib.backend_bases import KeyEvent as mpl_key_event
import numpy as np
from numpy import Inf
import traceback
import sys
import logging
import simplejson as json
import gettext
import appTranslation as fcTranslate
import builtins
fcTranslate.apply_language('strings')
if '_' not in builtins.__dict__:
_ = gettext.gettext
@@ -781,7 +760,8 @@ class ToolPaint(AppTool, Gerber):
# make the diameter column editable
for row in range(tool_id):
self.ui.tools_table.item(row, 1).setFlags(
QtCore.Qt.ItemFlag.ItemIsEditable | QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEnabled)
QtCore.Qt.ItemFlag.ItemIsEditable | QtCore.Qt.ItemFlag.ItemIsSelectable |
QtCore.Qt.ItemFlag.ItemIsEnabled)
# all the tools are selected by default
self.ui.tools_table.selectColumn(0)
@@ -1235,7 +1215,7 @@ class ToolPaint(AppTool, Gerber):
self.app.ui.notebook.setDisabled(True)
elif self.select_method == 3: # _("Reference Object")
self.bound_obj_name = self.reference_combo.currentText()
self.bound_obj_name = self.ui.reference_combo.currentText()
# Get source object.
try:
self.bound_obj = self.app.collection.get_by_name(self.bound_obj_name)
@@ -1703,7 +1683,8 @@ class ToolPaint(AppTool, Gerber):
except grace:
return "fail"
except Exception as ee:
self.app.log.error("ToolPaint.paint_polygon_worker() Laser Lines -> Identify flashes/traces--> %s" % str(ee))
self.app.log.error(
"ToolPaint.paint_polygon_worker() Laser Lines -> Identify flashes/traces--> %s" % str(ee))
cpoly = AppRTreeStorage()
pads_lines_list = []
@@ -2155,15 +2136,15 @@ class ToolPaint(AppTool, Gerber):
geo_elems = list(geo_res.get_objects())
# See if the polygon was completely cleared
pp_cleared = unary_union(geo_elems).buffer(tool_dia / 2.0)
rest = pp.difference(pp_cleared)
if rest and not rest.is_empty:
rest_geo = pp.difference(pp_cleared)
if rest_geo and not rest_geo.is_empty:
try:
for r in rest:
for r in rest_geo:
if r.is_valid:
rest_list.append(r)
except TypeError:
if rest.is_valid:
rest_list.append(rest)
if rest_geo.is_valid:
rest_list.append(rest_geo)
if geo_res:
cleared_geo += geo_elems
@@ -2195,15 +2176,15 @@ class ToolPaint(AppTool, Gerber):
# See if the polygon was completely cleared
pp_cleared = unary_union(geo_elems).buffer(tool_dia / 2.0)
rest = poly_buf.difference(pp_cleared)
if rest and not rest.is_empty:
rest_geo = poly_buf.difference(pp_cleared)
if rest_geo and not rest_geo.is_empty:
try:
for r in rest:
for r in rest_geo:
if r.is_valid:
rest_list.append(r)
except TypeError:
if rest.is_valid:
rest_list.append(rest)
if rest_geo.is_valid:
rest_list.append(rest_geo)
if geo_res:
cleared_geo += geo_elems
@@ -2473,7 +2454,8 @@ class ToolPaint(AppTool, Gerber):
if obj.kind == 'gerber':
# I don't do anything here, like buffering when the Gerber is loaded without buffering????!!!!
if self.app.options["gerber_buffering"] == 'no':
msg = '%s %s %s' % (_("Paint Plugin."), _("Paint all polygons task started."), _("Buffering geometry..."))
msg = '%s %s %s' % (_("Paint Plugin."), _("Paint all polygons task started."),
_("Buffering geometry..."))
self.app.inform.emit(msg)
else:
self.app.inform.emit('%s %s' % (_("Paint Plugin."), _("Paint all polygons task started.")))
@@ -2780,8 +2762,7 @@ class ToolPaint(AppTool, Gerber):
for k in o:
try:
minx_, miny_, maxx_, maxy_ = bounds_rec(k)
except Exception as e:
# log.error("ToolPaint.bounds() --> %s" % str(e))
except Exception:
return
minx = min(minx, minx_)