diff --git a/CHANGELOG.md b/CHANGELOG.md index df9d4582..3b282580 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ CHANGELOG for FlatCAM beta - added some more logs to the SVG import - fixed minor issue with not having the Cancel option on exiting the GCode Editor through the Toolbar button - in Gerber Editor fixed the canvas context menu not showing +- made sure that the Offset fields in the Properties Tab are updated on object: move, origin change, transformations 19.01.2021 diff --git a/appObjects/FlatCAMExcellon.py b/appObjects/FlatCAMExcellon.py index 0d1dae86..1de6108d 100644 --- a/appObjects/FlatCAMExcellon.py +++ b/appObjects/FlatCAMExcellon.py @@ -187,10 +187,13 @@ class ExcellonObject(FlatCAMObj, Excellon): self.units_found = self.app.defaults['units'] + self.set_offset_values() + + def set_offset_values(self): xmin, ymin, xmax, ymax = self.bounds() center_coords = ( - xmin + abs((xmax - xmin) / 2), - ymin + abs((ymax - ymin) / 2) + self.app.dec_format((xmin + abs((xmax - xmin) / 2)), self.decimals), + self.app.dec_format((ymin + abs((ymax - ymin) / 2)), self.decimals) ) self.ui.offsetvector_entry.set_value(str(center_coords)) diff --git a/appObjects/FlatCAMGeometry.py b/appObjects/FlatCAMGeometry.py index 7fc65f20..b3e68d2f 100644 --- a/appObjects/FlatCAMGeometry.py +++ b/appObjects/FlatCAMGeometry.py @@ -685,17 +685,20 @@ class GeometryObject(FlatCAMObj, Geometry): # # self.launch_job.connect(self.mtool_gen_cncjob) - xmin, ymin, xmax, ymax = self.bounds() - center_coords = ( - xmin + abs((xmax - xmin) / 2), - ymin + abs((ymax - ymin) / 2) - ) - self.ui.offsetvector_entry.set_value(str(center_coords)) + self.set_offset_values() # Show/Hide Advanced Options app_mode = self.app.defaults["global_app_level"] self.change_level(app_mode) + def set_offset_values(self): + xmin, ymin, xmax, ymax = self.bounds() + center_coords = ( + self.app.dec_format((xmin + abs((xmax - xmin) / 2)), self.decimals), + self.app.dec_format((ymin + abs((ymax - ymin) / 2)), self.decimals) + ) + self.ui.offsetvector_entry.set_value(str(center_coords)) + def change_level(self, level): """ diff --git a/appObjects/FlatCAMGerber.py b/appObjects/FlatCAMGerber.py index 16f64894..88a4bfde 100644 --- a/appObjects/FlatCAMGerber.py +++ b/appObjects/FlatCAMGerber.py @@ -195,10 +195,13 @@ class GerberObject(FlatCAMObj, Gerber): self.build_ui() self.units_found = self.app.defaults['units'] + self.set_offset_values() + + def set_offset_values(self): xmin, ymin, xmax, ymax = self.bounds() center_coords = ( - xmin + abs((xmax - xmin) / 2), - ymin + abs((ymax - ymin) / 2) + self.app.dec_format((xmin + abs((xmax - xmin) / 2)), self.decimals), + self.app.dec_format((ymin + abs((ymax - ymin) / 2)), self.decimals) ) self.ui.offsetvector_entry.set_value(str(center_coords)) diff --git a/appTools/ToolMove.py b/appTools/ToolMove.py index c3f249b1..54e8cfef 100644 --- a/appTools/ToolMove.py +++ b/appTools/ToolMove.py @@ -189,6 +189,12 @@ class ToolMove(AppTool): sel_obj.options['xmax'] = c sel_obj.options['ymax'] = d + try: + sel_obj.set_offset_values() + except AttributeError: + # not all objects have this method + pass + # update the source_file with the new positions for sel_obj in obj_list: out_name = sel_obj.options["name"] diff --git a/appTools/ToolTransform.py b/appTools/ToolTransform.py index 05cbd761..91bc1802 100644 --- a/appTools/ToolTransform.py +++ b/appTools/ToolTransform.py @@ -321,6 +321,13 @@ class ToolTransform(AppTool): sel_obj.rotate(-num, point=(px, py)) self.app.app_obj.object_changed.emit(sel_obj) + # make sure to update the Offset field in Properties Tab + try: + sel_obj.set_offset_values() + except AttributeError: + # not all objects have this attribute + pass + # add information to the object that it was changed and how much sel_obj.options['rotate'] = num sel_obj.plot() @@ -393,6 +400,14 @@ class ToolTransform(AppTool): # add information to the object that it was changed and how much sel_obj.options['skew_x'] = xvalue sel_obj.options['skew_y'] = yvalue + + # make sure to update the Offset field in Properties Tab + try: + sel_obj.set_offset_values() + except AttributeError: + # not all objects have this attribute + pass + self.app.app_obj.object_changed.emit(sel_obj) sel_obj.plot() self.app.inform.emit('[success] %s %s %s...' % (_('Skew on the'), str(axis), _("axis done"))) @@ -419,6 +434,14 @@ class ToolTransform(AppTool): # add information to the object that it was changed and how much sel_obj.options['scale_x'] = xfactor sel_obj.options['scale_y'] = yfactor + + # make sure to update the Offset field in Properties Tab + try: + sel_obj.set_offset_values() + except AttributeError: + # not all objects have this attribute + pass + self.app.app_obj.object_changed.emit(sel_obj) sel_obj.plot() @@ -448,6 +471,14 @@ class ToolTransform(AppTool): sel_obj.offset((0, num)) # add information to the object that it was changed and how much sel_obj.options['offset_y'] = num + + # make sure to update the Offset field in Properties Tab + try: + sel_obj.set_offset_values() + except AttributeError: + # not all objects have this attribute + pass + self.app.app_obj.object_changed.emit(sel_obj) sel_obj.plot() diff --git a/app_Main.py b/app_Main.py index 9ce53968..92e8aa63 100644 --- a/app_Main.py +++ b/app_Main.py @@ -2609,6 +2609,8 @@ class App(QtCore.QObject): if self.call_source == 'app': return + # This is the object that exit from the Editor. It may be the edited object but it can be a new object + # created by the Editor edited_obj = self.collection.get_active() if cleanup is None: @@ -2739,6 +2741,13 @@ class App(QtCore.QObject): _("Select a Gerber, Geometry, Excellon or CNCJob Object to update.")) return + # make sure to update the Offset field in Properties Tab + try: + edited_obj.set_offset_values() + except AttributeError: + # not all objects have this attribute + pass + self.inform.emit('[selected] %s %s' % (obj_type, _("is updated, returning to App..."))) elif response == bt_no: # show the Tools Toolbar @@ -5016,6 +5025,14 @@ class App(QtCore.QObject): obj.options['ymin'] = b obj.options['xmax'] = c obj.options['ymax'] = d + + # make sure to update the Offset field in Properties Tab + try: + obj.set_offset_values() + except AttributeError: + # not all objects have this attribute + pass + self.inform.emit('[success] %s...' % _('Origin set')) for obj in obj_list: @@ -5107,6 +5124,13 @@ class App(QtCore.QObject): obj.options['xmax'] = c obj.options['ymax'] = d + # make sure to update the Offset field in Properties Tab + try: + obj.set_offset_values() + except AttributeError: + # not all objects have this attribute + pass + for obj in obj_list: obj.plot() self.plotcanvas.fit_view() @@ -5133,7 +5157,7 @@ class App(QtCore.QObject): def on_custom_origin(self, use_thread=True): """ - Move selected objects to be centered in origin. + Move selected objects to be centered in certain standard locations of the object (corners and center). :param use_thread: Control if to use threaded operation. Boolean. :return: """ @@ -5242,6 +5266,13 @@ class App(QtCore.QObject): obj.options['xmax'] = c obj.options['ymax'] = d + # make sure to update the Offset field in Properties Tab + try: + obj.set_offset_values() + except AttributeError: + # not all objects have this attribute + pass + for obj in obj_list: obj.plot() self.plotcanvas.fit_view() @@ -6603,6 +6634,14 @@ class App(QtCore.QObject): for obj in obj_list: obj.skew(num, 0, point=(xminimal, yminimal)) + + # make sure to update the Offset field in Properties Tab + try: + obj.set_offset_values() + except AttributeError: + # not all objects have this attribute + pass + obj.plot() self.app_obj.object_changed.emit(obj) self.inform.emit('[success] %s' % _("Skew on X axis done.")) @@ -6643,6 +6682,14 @@ class App(QtCore.QObject): for obj in obj_list: obj.skew(0, num, point=(xminimal, yminimal)) + + # make sure to update the Offset field in Properties Tab + try: + obj.set_offset_values() + except AttributeError: + # not all objects have this attribute + pass + obj.plot() self.app_obj.object_changed.emit(obj) self.inform.emit('[success] %s' % _("Skew on Y axis done."))