diff --git a/CHANGELOG.md b/CHANGELOG.md index 68e465bd..96187f61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,9 @@ CHANGELOG for FlatCAM beta - for all centering functionality, now if the moved object is of 'geometry' kind it will have the source_file attribute updated with DXF code - modified the centering in origin functionality to include a selection of choices in a dialog - fixed Locate in Object functionality to work in the situations where there are negative bounds values +- Gerber Editor - the vertex number points are now calculated also for a selection of shapes +- Geometry Editor - the vertex number points are now calculated also for a selection of shapes +- Geometry Editor - made sure that the shapes cannot be selected while the simplification is in process because it will mess things 13.12.2020 diff --git a/appEditors/AppGeoEditor.py b/appEditors/AppGeoEditor.py index 4345a932..0f7bdfc1 100644 --- a/appEditors/AppGeoEditor.py +++ b/appEditors/AppGeoEditor.py @@ -2593,6 +2593,10 @@ class FCSelect(DrawTool): # list where we store the overlapped shapes under our mouse left click position over_shape_list = [] + if self.draw_app.interdict_selection is True: + self.draw_app.app.inform.emit('[WARNING_NOTCL] %s' % _("Selection not allowed. Wait ...")) + return + # pos[0] and pos[1] are the mouse click coordinates (x, y) for ____ in self.storage.get_objects(): # first method of click selection -> inconvenient @@ -3352,6 +3356,10 @@ class AppGeoEditor(QtCore.QObject): self.app = app self.canvas = app.plotcanvas self.decimals = app.decimals + self.units = self.app.defaults['units'] + + # when True the Editor can't do selection due of an ongoing process + self.interdict_selection = False self.geo_edit_widget = QtWidgets.QWidget() # ## Box for custom widgets @@ -3526,7 +3534,6 @@ class AppGeoEditor(QtCore.QObject): self.geo_tol_entry.set_precision(self.decimals) self.geo_tol_entry.setSingleStep(10 ** -self.decimals) self.geo_tol_entry.set_range(0.0000, 10000.0000) - self.geo_tol_entry.set_value(10 ** -self.decimals) grid0.addWidget(simplification_tol_lbl, 32, 0) grid0.addWidget(self.geo_tol_entry, 32, 1, 1, 2) @@ -3820,7 +3827,7 @@ class AppGeoEditor(QtCore.QObject): self.is_empty_entry.set_value('None') self.is_valid_entry.set_value('None') self.geo_vertex_entry.set_value(0.0) - self.geo_tol_entry.set_value(10 ** -self.decimals) + self.geo_tol_entry.set_value(0.01 if self.units == 'MM' else 0.0004) self.geo_zoom.set_value(False) def build_ui(self): @@ -3874,6 +3881,7 @@ class AppGeoEditor(QtCore.QObject): def update_ui(self): self.selected = [] last_obj_shape = None + last_id = None selected_tree_items = self.tw.selectedItems() for sel in selected_tree_items: @@ -3882,6 +3890,7 @@ class AppGeoEditor(QtCore.QObject): if id(obj_shape) == int(sel.text(0)): self.selected.append(obj_shape) last_obj_shape = obj_shape + last_id = sel.text(0) except ValueError: pass @@ -3969,6 +3978,8 @@ class AppGeoEditor(QtCore.QObject): self.geo_coords_entry.setText(str(coords)) self.geo_vertex_entry.set_value(vertex_nr) + self.app.inform.emit('%s: %s' % (_("Last selected shape ID"), str(last_id))) + def on_tree_geo_click(self): try: @@ -3988,6 +3999,7 @@ class AppGeoEditor(QtCore.QObject): def task_job(): with self.app.proc_container.new('%s...' % _("Simplify")): + self.interdict_selection = True for sel in selected_tree_items: for obj_shape in self.storage.get_objects(): try: @@ -4004,7 +4016,7 @@ class AppGeoEditor(QtCore.QObject): self.add_shape(DrawToolShape(geo), build_ui=False) self.plot_all() - + self.interdict_selection = False self.build_ui_sig.emit() self.app.worker_task.emit({'fcn': task_job, 'params': []}) @@ -4784,7 +4796,9 @@ class AppGeoEditor(QtCore.QObject): self.selected = [] self.selected = sel_objects_list - # if selection is done on canvas update the Tree in Selected Tab with the selection + # ############################################################################################################# + # ######### if selection is done on canvas update the Tree in Selected Tab with the selection ############### + # ############################################################################################################# try: self.tw.itemClicked.disconnect(self.on_tree_geo_click) except (AttributeError, TypeError): @@ -4803,6 +4817,23 @@ class AppGeoEditor(QtCore.QObject): iterator += 1 + # ############################################################################################################# + # ################### calculate vertex numbers for all selected shapes ###################################### + # ############################################################################################################# + vertex_nr = 0 + for sha in sel_objects_list: + sha_geo_solid = sha.geo + if sha_geo_solid.geom_type == 'Polygon': + sha_geo_solid_coords = list(sha_geo_solid.exterior.coords) + elif sha_geo_solid.geom_type in ['LinearRing', 'LineString']: + sha_geo_solid_coords = list(sha_geo_solid.coords) + else: + sha_geo_solid_coords = [] + + vertex_nr += len(sha_geo_solid_coords) + + self.geo_vertex_entry.set_value(vertex_nr) + self.tw.itemClicked.connect(self.on_tree_geo_click) self.plot_all() @@ -5154,6 +5185,8 @@ class AppGeoEditor(QtCore.QObject): self.set_ui() + self.units = self.app.defaults['units'] + # Hide original geometry self.fcgeometry = fcgeometry fcgeometry.visible = False diff --git a/appEditors/AppGerberEditor.py b/appEditors/AppGerberEditor.py index 69a07ca9..f3481505 100644 --- a/appEditors/AppGerberEditor.py +++ b/appEditors/AppGerberEditor.py @@ -2953,7 +2953,7 @@ class AppGerberEditor(QtCore.QObject): self.complete = True - self.set_ui() + self.set_editor_ui() self.app.log.debug("Initialization of the Gerber Editor is finished ...") def make_callback(self, the_tool): @@ -2990,7 +2990,7 @@ class AppGerberEditor(QtCore.QObject): self.tool_shape.pool = pool self.pool = pool - def set_ui(self): + def set_editor_ui(self): # updated units self.units = self.app.defaults['units'].upper() self.decimals = self.app.decimals @@ -3567,7 +3567,6 @@ class AppGerberEditor(QtCore.QObject): current_apid = self.last_aperture_selected new_geo['apid'] = deepcopy(current_apid) - print(current_apid) if 'solid' in obj_shape.geo: new_geo['geo']['solid'] = obj_shape.geo['solid'].simplify(tolerance=tol) @@ -3657,6 +3656,7 @@ class AppGerberEditor(QtCore.QObject): self.ui.is_valid_entry.setText(str(validity)) self.ui.geo_coords_entry.setText(str(coords)) + self.ui.geo_vertex_entry.set_value(vertex_nr) def on_name_activate(self): @@ -4035,7 +4035,7 @@ class AppGerberEditor(QtCore.QObject): # self.grb_plot_promises.append(ap_code) # self.app.worker_task.emit({'fcn': job_thread, 'params': [ap_code]}) # - # self.set_ui() + # self.set_editor_ui() # # # do the delayed plot only if there is something to plot (the gerber is not empty) # try: @@ -4196,7 +4196,7 @@ class AppGerberEditor(QtCore.QObject): def on_multiprocessing_finished(self): self.app.proc_container.update_view_text(' %s' % _("Setting up the UI")) self.app.inform.emit('[success] %s.' % _("Adding geometry finished. Preparing the GUI")) - self.set_ui() + self.set_editor_ui() self.build_ui(first_run=True) self.plot_all() @@ -4316,9 +4316,6 @@ class AppGerberEditor(QtCore.QObject): new_poly = new_poly.buffer(0.00000001) new_poly = new_poly.buffer(-0.00000001) - # for ad in grb_obj.apertures: - # print(ad, grb_obj.apertures[ad]) - try: __ = iter(new_poly) except TypeError: @@ -4707,6 +4704,25 @@ class AppGerberEditor(QtCore.QObject): self.last_aperture_selected = aper self.ui.apertures_table.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection) + # ############################################################################################################# + # ######################### calculate vertex numbers for all selected shapes ################################## + # ############################################################################################################# + vertex_nr = 0 + for sha in self.selected: + sha_geo = sha.geo + if 'solid' in sha_geo: + sha_geo_solid = sha_geo['solid'] + if sha_geo_solid.geom_type == 'Polygon': + sha_geo_solid_coords = list(sha_geo_solid.exterior.coords) + elif sha_geo_solid.geom_type in ['LinearRing', 'LineString']: + sha_geo_solid_coords = list(sha_geo_solid.coords) + else: + sha_geo_solid_coords = [] + + vertex_nr += len(sha_geo_solid_coords) + + self.ui.geo_vertex_entry.set_value(vertex_nr) + self.ui.apertures_table.cellPressed.connect(self.on_row_selected) self.plot_all()