- renamed the GeoEditor class/file to appGeoEditor from FlatCAMGeoEditor making it easier to see in the IDE tree structure

- some refactoring that lead to a working solution when using the Python 3.8 + PyQt 5.15
This commit is contained in:
Marius 2020-06-08 19:46:18 +03:00
parent d97d3eabd2
commit 05df0a61c2
17 changed files with 2240 additions and 2239 deletions

View File

@ -10,6 +10,8 @@ CHANGELOG for FlatCAM beta
8.06.2020
- minor changes in the way that the tools are installed and connected
- renamed the GeoEditor class/file to appGeoEditor from FlatCAMGeoEditor making it easier to see in the IDE tree structure
- some refactoring that lead to a working solution when using the Python 3.8 + PyQt 5.15
7.06.2020

View File

@ -10,7 +10,7 @@ from PyQt5.QtCore import Qt, QSettings
from camlib import distance, arc, FlatCAMRTreeStorage
from appGUI.GUIElements import FCEntry, FCComboBox, FCTable, FCDoubleSpinner, RadioSet, FCSpinner
from appEditors.FlatCAMGeoEditor import FCShapeTool, DrawTool, DrawToolShape, DrawToolUtilityShape, FlatCAMGeoEditor
from appEditors.appGeoEditor import FCShapeTool, DrawTool, DrawToolShape, DrawToolUtilityShape, appGeoEditor
from appParsers.ParseExcellon import Excellon
from shapely.geometry import LineString, LinearRing, MultiLineString, Polygon, MultiPolygon, Point
@ -935,7 +935,7 @@ class FCDrillResize(FCShapeTool):
return
if new_dia not in self.draw_app.olddia_newdia:
self.destination_storage = FlatCAMGeoEditor.make_storage()
self.destination_storage = appGeoEditor.make_storage()
self.draw_app.storage_dict[new_dia] = self.destination_storage
# self.olddia_newdia dict keeps the evidence on current tools diameters as keys and gets updated on values
@ -2560,7 +2560,7 @@ class FlatCAMExcEditor(QtCore.QObject):
return
if tool_dia not in self.olddia_newdia:
storage_elem = FlatCAMGeoEditor.make_storage()
storage_elem = appGeoEditor.make_storage()
self.storage_dict[tool_dia] = storage_elem
# self.olddia_newdia dict keeps the evidence on current tools diameters as keys and gets updated on values
@ -2615,7 +2615,7 @@ class FlatCAMExcEditor(QtCore.QObject):
for deleted_tool_dia in deleted_tool_dia_list:
# delete the storage used for that tool
storage_elem = FlatCAMGeoEditor.make_storage()
storage_elem = appGeoEditor.make_storage()
self.storage_dict[deleted_tool_dia] = storage_elem
self.storage_dict.pop(deleted_tool_dia, None)
@ -2679,7 +2679,7 @@ class FlatCAMExcEditor(QtCore.QObject):
# DESTINATION storage
# tool diameter is not used so we create a new tool with the desired diameter
if new_dia not in self.olddia_newdia:
destination_storage = FlatCAMGeoEditor.make_storage()
destination_storage = appGeoEditor.make_storage()
self.storage_dict[new_dia] = destination_storage
# self.olddia_newdia dict keeps the evidence on current tools diameters as keys and gets updated on values
@ -2910,7 +2910,7 @@ class FlatCAMExcEditor(QtCore.QObject):
self.mr = self.canvas.graph_event_connect('mouse_release', self.on_exc_click_release)
# make sure that the shortcuts key and mouse events will no longer be linked to the methods from FlatCAMApp
# but those from FlatCAMGeoEditor
# but those from appGeoEditor
if self.app.is_legacy is False:
self.app.plotcanvas.graph_event_disconnect('mouse_press', self.app.on_mouse_click_over_plot)
self.app.plotcanvas.graph_event_disconnect('mouse_move', self.app.on_mouse_move_over_plot)
@ -3052,7 +3052,7 @@ class FlatCAMExcEditor(QtCore.QObject):
# build the geometry for each tool-diameter, each drill will be represented by a '+' symbol
# and then add it to the storage elements (each storage elements is a member of a list
for tool_dia in self.points_edit:
storage_elem = FlatCAMGeoEditor.make_storage()
storage_elem = appGeoEditor.make_storage()
for point in self.points_edit[tool_dia]:
# make a '+' sign, the line length is the tool diameter
start_hor_line = ((point.x - (tool_dia / 2)), point.y)
@ -3073,7 +3073,7 @@ class FlatCAMExcEditor(QtCore.QObject):
shape_geo = line_geo.buffer(buf_value)
if tool_dia not in self.storage_dict:
storage_elem = FlatCAMGeoEditor.make_storage()
storage_elem = appGeoEditor.make_storage()
self.storage_dict[tool_dia] = storage_elem
if shape_geo is not None:

View File

@ -3778,7 +3778,7 @@ class FlatCAMGrbEditor(QtCore.QObject):
# Canvas events
# make sure that the shortcuts key and mouse events will no longer be linked to the methods from FlatCAMApp
# but those from FlatCAMGeoEditor
# but those from appGeoEditor
# first connect to new, then disconnect the old handlers
# don't ask why but if there is nothing connected I've seen issues

View File

@ -2523,12 +2523,12 @@ class FCSelect(DrawTool):
# it will not work for 3rd method of click selection
if not over_shape_list:
self.draw_app.selected = []
FlatCAMGeoEditor.draw_shape_idx = -1
appGeoEditor.draw_shape_idx = -1
else:
# if there are shapes under our click then advance through the list of them, one at the time in a
# circular way
FlatCAMGeoEditor.draw_shape_idx = (FlatCAMGeoEditor.draw_shape_idx + 1) % len(over_shape_list)
obj_to_add = over_shape_list[int(FlatCAMGeoEditor.draw_shape_idx)]
appGeoEditor.draw_shape_idx = (appGeoEditor.draw_shape_idx + 1) % len(over_shape_list)
obj_to_add = over_shape_list[int(appGeoEditor.draw_shape_idx)]
key_modifier = QtWidgets.QApplication.keyboardModifiers()
@ -2550,7 +2550,7 @@ class FCSelect(DrawTool):
self.draw_app.selected = []
self.draw_app.selected.append(obj_to_add)
except Exception as e:
log.error("[ERROR] FlatCAMGeoEditor.FCSelect.click_release() -> Something went bad. %s" % str(e))
log.error("[ERROR] appGeoEditor.FCSelect.click_release() -> Something went bad. %s" % str(e))
# if selection is done on canvas update the Tree in Selected Tab with the selection
try:
@ -2788,9 +2788,9 @@ class FCMove(FCShapeTool):
else:
# if there are shapes under our click then advance through the list of them, one at the time in a
# circular way
self.draw_app.draw_shape_idx = (FlatCAMGeoEditor.draw_shape_idx + 1) % len(over_shape_list)
self.draw_app.draw_shape_idx = (appGeoEditor.draw_shape_idx + 1) % len(over_shape_list)
try:
obj_to_add = over_shape_list[int(FlatCAMGeoEditor.draw_shape_idx)]
obj_to_add = over_shape_list[int(appGeoEditor.draw_shape_idx)]
except IndexError:
return
@ -3230,7 +3230,7 @@ class FCTransform(FCShapeTool):
# ###############################################
# ################ Main Application #############
# ###############################################
class FlatCAMGeoEditor(QtCore.QObject):
class appGeoEditor(QtCore.QObject):
# will emit the name of the object that was just selected
item_selected = QtCore.pyqtSignal(str)
@ -3243,7 +3243,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
# assert isinstance(app, FlatCAMApp.App), \
# "Expected the app to be a FlatCAMApp.App, got %s" % type(app)
super(FlatCAMGeoEditor, self).__init__()
super(appGeoEditor, self).__init__()
self.app = app
self.canvas = app.plotcanvas
@ -3316,7 +3316,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
# # ## Data
self.active_tool = None
self.storage = FlatCAMGeoEditor.make_storage()
self.storage = appGeoEditor.make_storage()
self.utility = []
# VisPy visuals
@ -3415,7 +3415,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
self.options[opt] = float(text_value)
except Exception as e:
entry.set_value(self.app.defaults[opt])
log.debug("FlatCAMGeoEditor.__init__().entry2option() --> %s" % str(e))
log.debug("appGeoEditor.__init__().entry2option() --> %s" % str(e))
return
def grid_changed(goption, gentry):
@ -3588,7 +3588,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
self.connect_canvas_event_handlers()
# initialize working objects
self.storage = FlatCAMGeoEditor.make_storage()
self.storage = appGeoEditor.make_storage()
self.utility = []
self.selected = []
@ -3701,7 +3701,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
# for w in sel_tab_widget_list:
# w.setEnabled(True)
# except Exception as e:
# log.debug("FlatCAMGeoEditor.deactivate() --> %s" % str(e))
# log.debug("appGeoEditor.deactivate() --> %s" % str(e))
# Show original geometry
if self.fcgeometry:
@ -3727,7 +3727,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
if self.app.is_legacy is False:
# make sure that the shortcuts key and mouse events will no longer be linked to the methods from FlatCAMApp
# but those from FlatCAMGeoEditor
# but those from appGeoEditor
self.app.plotcanvas.graph_event_disconnect('mouse_press', self.app.on_mouse_click_over_plot)
self.app.plotcanvas.graph_event_disconnect('mouse_move', self.app.on_mouse_move_over_plot)
self.app.plotcanvas.graph_event_disconnect('mouse_release', self.app.on_mouse_click_release_over_plot)
@ -3958,7 +3958,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
self.shapes.clear(update=True)
self.tool_shape.clear(update=True)
# self.storage = FlatCAMGeoEditor.make_storage()
# self.storage = appGeoEditor.make_storage()
self.replot()
def edit_fcgeometry(self, fcgeometry, multigeo_tool=None):
@ -4567,10 +4567,10 @@ class FlatCAMGeoEditor(QtCore.QObject):
elif isinstance(geom, LineString) and geom is not None:
geom = LineString(geom.coords[::-1])
else:
log.debug("FlatCAMGeoEditor.on_shape_complete() Error --> Unexpected Geometry %s" %
log.debug("appGeoEditor.on_shape_complete() Error --> Unexpected Geometry %s" %
type(geom))
except Exception as e:
log.debug("FlatCAMGeoEditor.on_shape_complete() Error --> %s" % str(e))
log.debug("appGeoEditor.on_shape_complete() Error --> %s" % str(e))
return 'fail'
shape_list = []
@ -4757,7 +4757,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
try:
results = geo_shapes[0].geo
except Exception as e:
log.debug("FlatCAMGeoEditor.intersection() --> %s" % str(e))
log.debug("appGeoEditor.intersection() --> %s" % str(e))
self.app.inform.emit('[WARNING_NOTCL] %s' %
_("A selection of at least 2 geo items is required to do Intersection."))
self.select_tool('select')
@ -4792,7 +4792,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
try:
intersector = geo_shapes[0].geo
except Exception as e:
log.debug("FlatCAMGeoEditor.intersection() --> %s" % str(e))
log.debug("appGeoEditor.intersection() --> %s" % str(e))
self.app.inform.emit('[WARNING_NOTCL] %s' %
_("A selection of at least 2 geo items is required to do Intersection."))
self.select_tool('select')

View File

@ -19,7 +19,7 @@ from appGUI.preferences.excellon.ExcellonPreferencesUI import ExcellonPreference
from appGUI.preferences.general.GeneralPreferencesUI import GeneralPreferencesUI
from appGUI.preferences.geometry.GeometryPreferencesUI import GeometryPreferencesUI
from appGUI.preferences.gerber.GerberPreferencesUI import GerberPreferencesUI
from appEditors.FlatCAMGeoEditor import FCShapeTool
from appEditors.appGeoEditor import FCShapeTool
from matplotlib.backend_bases import KeyEvent as mpl_key_event
import webbrowser

View File

@ -15,7 +15,7 @@ from shapely.geometry import Point, MultiLineString, Polygon
import appTranslation as fcTranslate
from camlib import FlatCAMRTreeStorage
from appEditors.FlatCAMGeoEditor import DrawToolShape
from appEditors.appGeoEditor import DrawToolShape
from copy import copy
import math

View File

@ -78,7 +78,7 @@ from appGUI.GUIElements import FCFileSaveDialog, message_dialog, FlatCAMSystemTr
from appPreProcessor import load_preprocessors
# FlatCAM appEditors
from appEditors.FlatCAMGeoEditor import FlatCAMGeoEditor
from appEditors.appGeoEditor import appGeoEditor
from appEditors.FlatCAMExcEditor import FlatCAMExcEditor
from appEditors.FlatCAMGrbEditor import FlatCAMGrbEditor
from appEditors.FlatCAMTextEditor import TextEditor
@ -1321,7 +1321,6 @@ class App(QtCore.QObject):
# ########################################## Tools and Plugins ##############################################
# ###########################################################################################################
self.shell = None
self.dblsidedtool = None
self.distance_tool = None
@ -1553,7 +1552,7 @@ class App(QtCore.QObject):
# watch out for the position of the editors instantiation ... if it is done before a save of the default values
# at the first launch of the App , the editors will not be functional.
try:
self.geo_editor = FlatCAMGeoEditor(self)
self.geo_editor = appGeoEditor(self)
except Exception as es:
log.debug("app_Main.__init__() --> Geo Editor Error: %s" % str(es))
@ -3396,12 +3395,12 @@ class App(QtCore.QObject):
# When the main event loop is not started yet in which case the qApp.quit() will do nothing
# we use the following command
minor_v = sys.version_info.minor
if minor_v < 8:
# make sure that the app closes
sys.exit(0)
else:
os._exit(0) # fix to work with Python 3.8
# minor_v = sys.version_info.minor
# if minor_v < 8:
# # make sure that the app closes
# sys.exit(0)
# else:
# os._exit(0) # fix to work with Python 3.8
@staticmethod
def kill_app():
@ -6594,7 +6593,7 @@ class App(QtCore.QObject):
if self.call_source != 'app':
self.editor2object(cleanup=True)
# ## EDITOR section
self.geo_editor = FlatCAMGeoEditor(self)
self.geo_editor = appGeoEditor(self)
self.exc_editor = FlatCAMExcEditor(self)
self.grb_editor = FlatCAMGrbEditor(self)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff