- 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

@@ -4,20 +4,8 @@
# Date: 3/10/2019 #
# MIT Licence #
# ##########################################################
import math
from PyQt6 import QtCore, QtWidgets, QtGui
from appTool import AppTool
from appGUI.GUIElements import RadioSet, FCDoubleSpinner, FCCheckBox, \
OptionalHideInputSection, FCComboBox, FCFileSaveDialog, FCButton, FCLabel, FCSpinner, \
VerticalScrollArea, FCGridLayout, FCFrame, FCComboBox2
from copy import deepcopy
import logging
from shapely.geometry import Polygon, MultiPolygon, Point, LineString, LinearRing
import shapely.affinity as affinity
from shapely.ops import unary_union
from appTool import *
from reportlab.graphics import renderPDF
from reportlab.pdfgen import canvas
@@ -30,10 +18,6 @@ from xml.dom.minidom import parseString as parse_xml_string
from lxml import etree as ET
from io import StringIO
import gettext
import appTranslation as fcTranslate
import builtins
fcTranslate.apply_language('strings')
if '_' not in builtins.__dict__:
_ = gettext.gettext
@@ -640,13 +624,13 @@ class Film(AppTool):
return "Could not retrieve object: %s" % obj_name
try:
box = self.app.collection.get_by_name(str(box_name))
box_obj = self.app.collection.get_by_name(str(box_name))
except Exception:
return "Could not retrieve object: %s" % box_name
if box is None:
if box_obj is None:
self.app.inform.emit('[WARNING_NOTCL] %s: %s' % (_("No object Box. Using instead"), obj))
box = obj
box_obj = obj
scale_factor_x = scale_factor_x
scale_factor_y = scale_factor_y
@@ -668,7 +652,7 @@ class Film(AppTool):
scale_factor_x += dpi_rate
scale_factor_y += dpi_rate
transformed_box_geo = self.transform_geometry(box, scale_factor_x=scale_factor_x,
transformed_box_geo = self.transform_geometry(box_obj, scale_factor_x=scale_factor_x,
scale_factor_y=scale_factor_y,
scale_reference=scale_reference, scale_type=scale_type,
skew_factor_x=skew_factor_x, skew_factor_y=skew_factor_y,
@@ -862,13 +846,13 @@ class Film(AppTool):
return "Could not retrieve object: %s" % obj_name
try:
box = self.app.collection.get_by_name(str(box_name))
box_obj = self.app.collection.get_by_name(str(box_name))
except Exception:
return "Could not retrieve object: %s" % box_name
if box is None:
if box_obj is None:
self.app.inform.emit('[WARNING_NOTCL] %s: %s' % (_("No object Box. Using instead"), obj))
box = obj
box_obj = obj
scale_factor_x = scale_factor_x
scale_factor_y = scale_factor_y
@@ -890,7 +874,7 @@ class Film(AppTool):
scale_factor_x += dpi_rate
scale_factor_y += dpi_rate
transformed_box_geo = self.transform_geometry(box, scale_factor_x=scale_factor_x,
transformed_box_geo = self.transform_geometry(box_obj, scale_factor_x=scale_factor_x,
scale_factor_y=scale_factor_y,
scale_reference=scale_reference, scale_type=scale_type,
skew_factor_x=skew_factor_x, skew_factor_y=skew_factor_y,
@@ -1113,7 +1097,7 @@ class Film(AppTool):
val_x = ((xmax - xmin) + scale_factor_x) / (xmax - xmin)
val_y = ((ymax - ymin) + scale_factor_y) / (ymax - ymin)
transformed_geo = affinity.scale(transformed_geo, val_x, val_y, origin=ref_scale_val)
transformed_geo = scale(transformed_geo, val_x, val_y, origin=ref_scale_val)
# return transformed_geo
@@ -1192,15 +1176,15 @@ class Film(AppTool):
future_y = (ymax - ymin) * skew_factor_y - (ymax - ymin)
skew_angle_x = math.degrees(math.atan2(future_x, ((ymax - ymin) * 0.5)))
skew_angle_y = math.degrees(math.atan2(future_y, ((xmax - xmin) * 0.5)))
transformed_geo = affinity.skew(transformed_geo, skew_angle_x, skew_angle_y, origin=ref_skew_val)
transformed_geo = skew(transformed_geo, skew_angle_x, skew_angle_y, origin=ref_skew_val)
if mirror:
if mirror == 'x':
transformed_geo = affinity.scale(transformed_geo, 1.0, -1.0, origin='center')
transformed_geo = scale(transformed_geo, 1.0, -1.0, origin='center')
if mirror == 'y':
transformed_geo = affinity.scale(transformed_geo, -1.0, 1.0, origin='center')
transformed_geo = scale(transformed_geo, -1.0, 1.0, origin='center')
if mirror == 'both':
transformed_geo = affinity.scale(transformed_geo, -1.0, -1.0, origin='center')
transformed_geo = scale(transformed_geo, -1.0, -1.0, origin='center')
return transformed_geo