diff --git a/CHANGELOG.md b/CHANGELOG.md
index 59a97711..698b8eb0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,11 @@ CHANGELOG for FlatCAM beta
- solved a Shapely 2.0 deprecation warning
- more Qt6 port bugs fixed
- in Autolevelling Plugin modified the UI; work in progress - the frame disable is not working
+- in Excellon Editor and Geometry Editor solved some Shapely 2.0 deprecation warnings
+- in Excellon Editor made sure that the tool diameter is always updated before adding a new drill (or drill array)
+- changing units is not possible while in Editors
+- changing units outside the Preferences will make no permanent changes
+- deleting all shapes from the shapes collection (OpenGl graphics) will reset also the index in the collection data dict
25.09.2021
diff --git a/appEditors/AppExcEditor.py b/appEditors/AppExcEditor.py
index 28777b8e..306ce018 100644
--- a/appEditors/AppExcEditor.py
+++ b/appEditors/AppExcEditor.py
@@ -91,7 +91,7 @@ class SelectEditorExc(FCShapeTool):
# constrain selection to happen only within a certain bounding box; it works only for MultiLineStrings
if isinstance(closest_shape.geo, MultiLineString):
- x_coord, y_coord = closest_shape.geo[0].xy
+ x_coord, y_coord = closest_shape.geo.geoms[0].xy
delta = (x_coord[1] - x_coord[0])
# closest_shape_coords = (((x_coord[0] + delta / 2)), y_coord[0])
xmin = x_coord[0] - (0.7 * delta)
@@ -272,6 +272,8 @@ class DrillAdd(FCShapeTool):
return DrawToolUtilityShape(self.util_shape(data))
def util_shape(self, point):
+ self.selected_dia = self.draw_app.tool2tooldia[self.draw_app.last_tool_selected]
+
if point[0] is None and point[1] is None:
point_x = self.draw_app.x
point_y = self.draw_app.y
@@ -287,7 +289,7 @@ class DrillAdd(FCShapeTool):
return MultiLineString([(start_hor_line, stop_hor_line), (start_vert_line, stop_vert_line)])
def make(self):
-
+ self.selected_dia = self.draw_app.tool2tooldia[self.draw_app.last_tool_selected]
try:
QtGui.QGuiApplication.restoreOverrideCursor()
except Exception:
@@ -525,6 +527,8 @@ class DrillArray(FCShapeTool):
return circular_geo
def util_shape(self, point):
+ self.selected_dia = self.draw_app.tool2tooldia[self.draw_app.last_tool_selected]
+
if point[0] is None and point[1] is None:
point_x = self.draw_app.x
point_y = self.draw_app.y
@@ -540,6 +544,7 @@ class DrillArray(FCShapeTool):
return MultiLineString([(start_hor_line, stop_hor_line), (start_vert_line, stop_vert_line)])
def make(self):
+ self.selected_dia = self.draw_app.tool2tooldia[self.draw_app.last_tool_selected]
self.geometry = []
geo = None
@@ -1609,7 +1614,11 @@ class MoveEditorExc(FCShapeTool):
def selection_bbox(self):
geo_list = []
for select_shape in self.draw_app.get_selected():
- geometric_data = select_shape.geo
+ if isinstance(select_shape.geo, (MultiLineString, MultiPolygon)):
+ geometric_data = select_shape.geo.geoms
+ else:
+ geometric_data = select_shape.geo
+
try:
for g in geometric_data:
geo_list.append(g)
@@ -2921,7 +2930,7 @@ class AppExcEditor(QtCore.QObject):
# all x.geo in self.storage_dict[storage] are MultiLinestring objects for drills
# each MultiLineString is made out of Linestrings
# select first Linestring object in the current MultiLineString
- first_linestring = x.geo[0]
+ first_linestring = x.geo.geoms[0]
# get it's coordinates
first_linestring_coords = first_linestring.coords
x_coord = first_linestring_coords[0][0] + (float(first_linestring.length / 2))
@@ -3638,22 +3647,19 @@ class AppExcEditor(QtCore.QObject):
def draw_utility_geometry(self, geo):
# Add the new utility shape
+
+ if isinstance(geo.geo, (MultiLineString, MultiPolygon)):
+ util_geo = geo.geo.geoms
+ else:
+ util_geo = geo.geo
+
try:
# this case is for the Font Parse
- for el in list(geo.geo):
- if type(el) == MultiPolygon:
- for poly in el:
+ for el in util_geo:
+ if isinstance(el, (MultiLineString, MultiPolygon)):
+ for sub_geo in el.geoms:
self.tool_shape.add(
- shape=poly,
- color=(self.app.defaults["global_draw_color"] + '80'),
- update=False,
- layer=0,
- tolerance=None
- )
- elif type(el) == MultiLineString:
- for linestring in el:
- self.tool_shape.add(
- shape=linestring,
+ shape=sub_geo,
color=(self.app.defaults["global_draw_color"] + '80'),
update=False,
layer=0,
@@ -3665,12 +3671,15 @@ class AppExcEditor(QtCore.QObject):
color=(self.app.defaults["global_draw_color"] + '80'),
update=False,
layer=0,
- tolerance=None
- )
+ tolerance=None)
except TypeError:
self.tool_shape.add(
- shape=geo.geo, color=(self.app.defaults["global_draw_color"] + '80'),
- update=False, layer=0, tolerance=None)
+ shape=util_geo,
+ color=(self.app.defaults["global_draw_color"] + '80'),
+ update=False,
+ layer=0,
+ tolerance=None)
+ # print(self.tool_shape.data)
self.tool_shape.redraw()
def replot(self):
@@ -3718,23 +3727,29 @@ class AppExcEditor(QtCore.QObject):
if geometry is None:
geometry = self.active_tool.geometry
+ if isinstance(geometry, (MultiLineString, MultiPolygon)):
+ use_geometry = geometry.geoms
+ else:
+ use_geometry = geometry
+
try:
- for geo in geometry:
+ for geo in use_geometry:
plot_elements += self.plot_shape(geometry=geo, color=color, linewidth=linewidth)
# ## Non-iterable
except TypeError:
# ## DrawToolShape
- if isinstance(geometry, DrawToolShape):
- plot_elements += self.plot_shape(geometry=geometry.geo, color=color, linewidth=linewidth)
+ if isinstance(use_geometry, DrawToolShape):
+ plot_elements += self.plot_shape(geometry=use_geometry.geo, color=color, linewidth=linewidth)
# ## Polygon: Descend into exterior and each interior.
- if isinstance(geometry, Polygon):
- plot_elements += self.plot_shape(geometry=geometry.exterior, color=color, linewidth=linewidth)
- plot_elements += self.plot_shape(geometry=geometry.interiors, color=color, linewidth=linewidth)
+ if isinstance(use_geometry, Polygon):
+ plot_elements += self.plot_shape(geometry=use_geometry.exterior, color=color, linewidth=linewidth)
+ plot_elements += self.plot_shape(geometry=use_geometry.interiors, color=color, linewidth=linewidth)
- if isinstance(geometry, (LineString, LinearRing)):
- plot_elements.append(self.shapes.add(shape=geometry, color=color, layer=0, tolerance=self.tolerance))
+ if isinstance(use_geometry, (LineString, LinearRing)):
+ plot_elements.append(self.shapes.add(shape=use_geometry, color=color, layer=0,
+ tolerance=self.tolerance))
if type(geometry) == Point:
pass
@@ -3837,6 +3852,7 @@ class AppExcEditor(QtCore.QObject):
if val == 'linear':
self.ui.array_circular_frame.hide()
self.ui.array_linear_frame.show()
+ self.app.inform.emit(_("Click to place ..."))
else:
self.delete_utility_geometry()
self.ui.array_circular_frame.show()
@@ -3847,6 +3863,7 @@ class AppExcEditor(QtCore.QObject):
if val == 'linear':
self.ui.slot_array_circular_frame.hide()
self.ui.slot_array_linear_frame.show()
+ self.app.inform.emit(_("Click to place ..."))
else:
self.delete_utility_geometry()
self.ui.slot_array_circular_frame.show()
diff --git a/appEditors/AppGeoEditor.py b/appEditors/AppGeoEditor.py
index 151c6a1c..c9d6c2b3 100644
--- a/appEditors/AppGeoEditor.py
+++ b/appEditors/AppGeoEditor.py
@@ -1697,31 +1697,35 @@ class DrawToolShape(object):
# Iterable: descend into each item.
try:
- for subo in o:
- pts += DrawToolShape.get_pts(subo)
+ if isinstance(o, (MultiPolygon, MultiLineString)):
+ for subo in o.geoms:
+ pts += DrawToolShape.get_pts(subo)
+ else:
+ for subo in o:
+ pts += DrawToolShape.get_pts(subo)
# Non-iterable
except TypeError:
- if o is not None:
- # DrawToolShape: descend into .geo.
- if isinstance(o, DrawToolShape):
- pts += DrawToolShape.get_pts(o.geo)
-
- # Descend into .exterior and .interiors
- elif type(o) == Polygon:
- pts += DrawToolShape.get_pts(o.exterior)
- for i in o.interiors:
- pts += DrawToolShape.get_pts(i)
- elif type(o) == MultiLineString:
- for line in o:
- pts += DrawToolShape.get_pts(line)
- # Has .coords: list them.
- else:
- if DrawToolShape.tolerance is not None:
- pts += list(o.simplify(DrawToolShape.tolerance).coords)
- else:
- pts += list(o.coords)
- else:
+ if o is None:
return
+
+ # DrawToolShape: descend into .geo.
+ if isinstance(o, DrawToolShape):
+ pts += DrawToolShape.get_pts(o.geo)
+
+ # Descend into .exterior and .interiors
+ elif isinstance(o, Polygon):
+ pts += DrawToolShape.get_pts(o.exterior)
+ for i in o.interiors:
+ pts += DrawToolShape.get_pts(i)
+ elif isinstance(o, (MultiLineString, MultiPolygon)):
+ for geo_pol_line in o.geoms:
+ pts += DrawToolShape.get_pts(geo_pol_line)
+ # Has .coords: list them.
+ else:
+ if DrawToolShape.tolerance is not None:
+ pts += list(o.simplify(DrawToolShape.tolerance).coords)
+ else:
+ pts += list(o.coords)
return pts
def __init__(self, geo: (BaseGeometry, list)):
diff --git a/appGUI/VisPyVisuals.py b/appGUI/VisPyVisuals.py
index 38d6854b..23d4ebee 100644
--- a/appGUI/VisPyVisuals.py
+++ b/appGUI/VisPyVisuals.py
@@ -335,6 +335,7 @@ class ShapeCollectionVisual(CompoundVisual):
:param update: bool
Set True to redraw collection
"""
+ self.last_key = -1
self.data.clear()
if update:
self.__update()
diff --git a/appGUI/preferences/PreferencesUIManager.py b/appGUI/preferences/PreferencesUIManager.py
index 67d81fbc..f994413a 100644
--- a/appGUI/preferences/PreferencesUIManager.py
+++ b/appGUI/preferences/PreferencesUIManager.py
@@ -33,6 +33,8 @@ class PreferencesUIManager:
self.inform = inform
self.ignore_tab_close_event = False
+ self.preferences_units = "MM"
+
# if Preferences are changed in the Edit -> Preferences tab the value will be set to True
self.preferences_changed_flag = False
@@ -1114,14 +1116,8 @@ class PreferencesUIManager:
# restore stylesheet to default for the statusBar icon
self.ui.pref_status_label.setStyleSheet("")
- try:
- self.ui.general_pref_form.general_app_group.units_radio.activated_custom.disconnect()
- except (TypeError, AttributeError):
- pass
-
self.defaults_write_form(source_dict=self.defaults.current_defaults)
- self.ui.general_pref_form.general_app_group.units_radio.activated_custom.connect(
- lambda: self.ui.app.on_toggle_units(no_pref=False))
+
self.defaults.update(self.defaults.current_defaults)
# Preferences save, update the color of the Preferences Tab text
@@ -1144,6 +1140,7 @@ class PreferencesUIManager:
self.defaults.reset_to_factory_defaults()
self.defaults_write_form()
self.on_preferences_edited()
+ self.ui.units_label.setText("[mm]")
self.inform.emit('[success] %s' % _("Preferences default values are restored."))
def save_defaults(self, silent=False, data_path=None, first_time=False):
diff --git a/appObjects/FlatCAMDocument.py b/appObjects/FlatCAMDocument.py
index 01bcd80b..c8af83a3 100644
--- a/appObjects/FlatCAMDocument.py
+++ b/appObjects/FlatCAMDocument.py
@@ -9,6 +9,7 @@
# ##########################################################
# File modified by: Marius Stanciu #
# ##########################################################
+from PyQt6 import QtGui
from appEditors.AppTextEditor import AppTextEditor
from appObjects.FlatCAMObj import *
diff --git a/appObjects/FlatCAMGerber.py b/appObjects/FlatCAMGerber.py
index 50344572..32a48bbf 100644
--- a/appObjects/FlatCAMGerber.py
+++ b/appObjects/FlatCAMGerber.py
@@ -943,7 +943,7 @@ class GerberObject(FlatCAMObj, Gerber):
plot_geometry = geometry.geoms if isinstance(geometry, (MultiPolygon, MultiLineString)) else geometry
for g in plot_geometry:
- if isinstance(g, (Polygon, LineString)):
+ if isinstance(g, (Polygon, LineString, LinearRing)):
self.add_shape(shape=g, color=used_color, face_color=used_face_color, visible=visible)
self.shapes.redraw(
diff --git a/appParsers/ParseGerber.py b/appParsers/ParseGerber.py
index 6afefb1c..a36c6e68 100644
--- a/appParsers/ParseGerber.py
+++ b/appParsers/ParseGerber.py
@@ -1701,11 +1701,15 @@ class Gerber(Geometry):
# features
if self.app.defaults['gerber_extra_buffering']:
candidate_geo = []
+ if isinstance(self.solid_geometry, MultiPolygon):
+ geo_to_buff = self.solid_geometry.geoms
+ else:
+ geo_to_buff = self.solid_geometry
try:
- for p in self.solid_geometry:
+ for p in geo_to_buff:
candidate_geo.append(p.buffer(-0.0000001))
except TypeError:
- candidate_geo.append(self.solid_geometry.buffer(-0.0000001))
+ candidate_geo.append(geo_to_buff.buffer(-0.0000001))
self.solid_geometry = candidate_geo
else:
@@ -2106,7 +2110,10 @@ class Gerber(Geometry):
# variables to display the percentage of work done
self.geo_len = 0
try:
- self.geo_len = len(self.solid_geometry)
+ if isinstance(self.solid_geometry, MultiPolygon):
+ self.geo_len = len(self.solid_geometry.geoms)
+ else:
+ self.geo_len = len(self.solid_geometry)
except TypeError:
self.geo_len = 1
diff --git a/app_Main.py b/app_Main.py
index 61e2e026..c276ae4a 100644
--- a/app_Main.py
+++ b/app_Main.py
@@ -1436,9 +1436,6 @@ class App(QtCore.QObject):
# #################################### GUI PREFERENCES SIGNALS ##############################################
# ###########################################################################################################
- self.ui.general_pref_form.general_app_group.units_radio.activated_custom.connect(
- lambda: self.on_toggle_units(no_pref=False))
-
# ##################################### Workspace Setting Signals ###########################################
self.ui.general_pref_form.general_app_set_group.wk_cb.currentIndexChanged.connect(
self.on_workspace_modified)
@@ -4590,99 +4587,23 @@ class App(QtCore.QObject):
self.ui.units_label.setText("[" + units.lower() + "]")
def on_toggle_units_click(self):
- try:
- self.ui.general_pref_form.general_app_group.units_radio.activated_custom.disconnect()
- except (TypeError, AttributeError):
- pass
+ new_units, factor = self.on_toggle_units()
+ if self.ui.plot_tab_area.currentWidget().objectName() == "preferences_tab":
+ if factor != 1: # means we had a unit change in the rest of the app
+ pref_units = self.preferencesUiManager.preferences_units
+ if pref_units != new_units:
+ self.preferencesUiManager.preferences_units = new_units
+ pref_factor = 25.4 if new_units == 'MM' else 1 / 25.4
+ self.scale_preferenes(pref_factor, new_units)
- if self.defaults["units"] == 'MM':
- self.ui.general_pref_form.general_app_group.units_radio.set_value("IN")
- else:
- self.ui.general_pref_form.general_app_group.units_radio.set_value("MM")
+ # update th new units in the preferences storage
+ self.defaults["units"] = new_units
- self.on_toggle_units(no_pref=True)
+ def scale_preferenes(self, sfactor, new_units):
+ self.preferencesUiManager.defaults_read_form()
- self.ui.general_pref_form.general_app_group.units_radio.activated_custom.connect(
- lambda: self.on_toggle_units(no_pref=False))
-
- def scale_defaults(self, sfactor, dimensions):
- for dim in dimensions:
- if dim in ['tools_mill_tooldia', 'tools_ncc_tools', 'tools_solderpaste_tools', 'tools_iso_tooldia',
- 'tools_paint_tooldia', 'tools_transform_ref_point', 'tools_cal_toolchange_xy',
- 'gerber_editor_newdim', 'tools_drill_toolchangexy', 'tools_drill_endxy',
- 'tools_mill_toolchangexy', 'tools_mill_endxy', 'tools_solderpaste_xy_toolchange']:
- if not self.defaults[dim] or self.defaults[dim] == '':
- continue
-
- if isinstance(self.defaults[dim], str):
- try:
- tools_diameters = eval(self.defaults[dim])
- except Exception as e:
- self.log.error("App.on_toggle_units().scale_defaults() lists --> %s" % str(e))
- continue
- elif isinstance(self.defaults[dim], (float, int)):
- tools_diameters = [self.defaults[dim]]
- else:
- tools_diameters = list(self.defaults[dim])
-
- if isinstance(tools_diameters, (tuple, list)):
- pass
- elif isinstance(tools_diameters, (int, float)):
- tools_diameters = [self.defaults[dim]]
- else:
- continue
-
- td_len = len(tools_diameters)
- conv_list = []
- for t in range(td_len):
- conv_list.append(self.dec_format(float(tools_diameters[t]) * sfactor, self.decimals))
-
- self.defaults[dim] = conv_list
- elif dim in ['global_gridx', 'global_gridy']:
- # format the number of decimals to the one specified in self.decimals
- try:
- val = float(self.defaults[dim]) * sfactor
- except Exception as e:
- self.log.error('App.on_toggle_units().scale_defaults() grids --> %s' % str(e))
- continue
-
- self.defaults[dim] = self.dec_format(val, self.decimals)
- else:
- # the number of decimals for the rest is kept unchanged
- if self.defaults[dim]:
- try:
- val = float(self.defaults[dim]) * sfactor
- except Exception as e:
- self.log.error(
- 'App.on_toggle_units().scale_defaults() standard --> Value: %s %s' % (str(dim), str(e))
- )
- continue
-
- self.defaults[dim] = self.dec_format(val, self.decimals)
-
- def on_toggle_units(self, no_pref=False):
- """
- Callback for the Units radio-button change in the Preferences tab.
- Changes the application's default units adn for the project too.
- If changing the project's units, the change propagates to all of
- the objects in the project.
-
- :return: None
- """
-
- self.defaults.report_usage("on_toggle_units")
-
- if self.toggle_units_ignore:
- return
-
- new_units = self.ui.general_pref_form.general_app_group.units_radio.get_value().upper()
-
- # If option is the same, then ignore
- if new_units == self.defaults["units"].upper():
- self.log.debug("on_toggle_units(): Same as previous, ignoring.")
- return
-
- # new_units = self.defaults["units"]
+ # update the defaults from form, some may assume that the conversion is enough and it's not
+ self.on_options_app2project()
# Keys in self.defaults for which to scale their values
dimensions = [
@@ -4723,7 +4644,7 @@ class App(QtCore.QObject):
'tools_drill_endxy', 'tools_drill_feedrate_z', 'tools_drill_toolchangez', "tools_drill_drill_overlap",
'tools_drill_offset', "tools_drill_toolchangexy", "tools_drill_startz", 'tools_drill_feedrate_rapid',
"tools_drill_feedrate_probe", "tools_drill_z_pdepth", "tools_drill_area_overz",
-
+
# NCC Tool
"tools_ncc_tools", "tools_ncc_margin", "tools_ncc_offset_value", "tools_ncc_cutz", "tools_ncc_tipdia",
"tools_ncc_newdia",
@@ -4794,11 +4715,86 @@ class App(QtCore.QObject):
"tools_invert_margin",
]
+ for dim in dimensions:
+ if dim in ['tools_mill_tooldia', 'tools_ncc_tools', 'tools_solderpaste_tools', 'tools_iso_tooldia',
+ 'tools_paint_tooldia', 'tools_transform_ref_point', 'tools_cal_toolchange_xy',
+ 'gerber_editor_newdim', 'tools_drill_toolchangexy', 'tools_drill_endxy',
+ 'tools_mill_toolchangexy', 'tools_mill_endxy', 'tools_solderpaste_xy_toolchange']:
+ if not self.defaults[dim] or self.defaults[dim] == '':
+ continue
- # The scaling factor depending on choice of units.
- factor = 25.4 if new_units == 'MM' else 1 / 25.4
+ if isinstance(self.defaults[dim], str):
+ try:
+ tools_diameters = eval(self.defaults[dim])
+ except Exception as e:
+ self.log.error("App.on_toggle_units().scale_defaults() lists --> %s" % str(e))
+ continue
+ elif isinstance(self.defaults[dim], (float, int)):
+ tools_diameters = [self.defaults[dim]]
+ else:
+ tools_diameters = list(self.defaults[dim])
- # Changing project units. Warn user.
+ if isinstance(tools_diameters, (tuple, list)):
+ pass
+ elif isinstance(tools_diameters, (int, float)):
+ tools_diameters = [self.defaults[dim]]
+ else:
+ continue
+
+ td_len = len(tools_diameters)
+ conv_list = []
+ for t in range(td_len):
+ conv_list.append(self.dec_format(float(tools_diameters[t]) * sfactor, self.decimals))
+
+ self.defaults[dim] = conv_list
+ elif dim in ['global_gridx', 'global_gridy']:
+ # format the number of decimals to the one specified in self.decimals
+ try:
+ val = float(self.defaults[dim]) * sfactor
+ except Exception as e:
+ self.log.error('App.on_toggle_units().scale_defaults() grids --> %s' % str(e))
+ continue
+
+ self.defaults[dim] = self.dec_format(val, self.decimals)
+ else:
+ # the number of decimals for the rest is kept unchanged
+ if self.defaults[dim]:
+ try:
+ val = float(self.defaults[dim]) * sfactor
+ except Exception as e:
+ self.log.error(
+ 'App.on_toggle_units().scale_defaults() standard --> Value: %s %s' % (str(dim), str(e))
+ )
+ continue
+
+ self.defaults[dim] = self.dec_format(val, self.decimals)
+
+ self.preferencesUiManager.defaults_write_form(fl_units=new_units)
+
+ def on_toggle_units(self):
+ """
+ Callback for the Units radio-button change in the Preferences tab.
+ Changes the application's default units adn for the project too.
+ If changing the project's units, the change propagates to all of
+ the objects in the project.
+
+ :return: The new application units. String: "IN" or "MM" with caps lock
+ """
+
+ if self.toggle_units_ignore:
+ return
+
+ new_units = self.defaults["units"]
+
+ # we can't change the units while inside the Editors
+ if self.call_source in ['geo_editor', 'grb_editor', 'exc_editor']:
+ msg = _("Units cannot be changed while the editor is active.")
+ self.inform.emit("[WARNING_NOTCL] %s" % msg)
+ return
+
+ # ##############################################################################################################
+ # Changing project units. Ask the user.
+ # ##############################################################################################################
msgbox = QtWidgets.QMessageBox()
msgbox.setWindowTitle(_("Toggle Units"))
msgbox.setWindowIcon(QtGui.QIcon(self.resource_location + '/toggle_units32.png'))
@@ -4815,26 +4811,21 @@ class App(QtCore.QObject):
response = msgbox.clickedButton()
if response == bt_ok:
- if no_pref is False:
- self.preferencesUiManager.defaults_read_form()
- self.scale_defaults(factor, dimensions)
- self.preferencesUiManager.defaults_write_form(fl_units=new_units)
+ new_units = "IN" if self.defaults['units'].upper() == "MM" else "MM"
- self.defaults["units"] = new_units
+ # The scaling factor depending on choice of units.
+ factor = 25.4 if new_units == 'MM' else 1 / 25.4
- # update the defaults from form, some may assume that the conversion is enough and it's not
- self.on_options_app2project()
-
- # update the objects
+ # update the Application objects with the new units
for obj in self.collection.get_list():
obj.convert_units(new_units)
-
# make that the properties stored in the object are also updated
self.app_obj.object_changed.emit(obj)
+
# rebuild the object UI
obj.build_ui()
- # change this only if the workspace is active
+ # update workspace if active
if self.defaults['global_workspace'] is True:
self.plotcanvas.draw_workspace(pagesize=self.defaults['global_workspaceT'])
@@ -4842,30 +4833,23 @@ class App(QtCore.QObject):
val_x = float(self.defaults['global_gridx']) * factor
val_y = val_x if self.ui.grid_gap_link_cb.isChecked() else float(self.defaults['global_gridx']) * factor
+ # update Object UI forms
current = self.collection.get_active()
if current is not None:
# the transfer of converted values to the UI form for Geometry is done local in the FlatCAMObj.py
if not isinstance(current, GeometryObject):
current.to_form()
- # replot all objects
+ # plot again all objects
self.plot_all()
-
- # set the status labels to reflect the current FlatCAM units
self.set_screen_units(new_units)
- # signal to the app that we changed the object properties and it should save the project
+ # flag for the app that we changed the object properties and it should save the project
self.should_we_save = True
self.inform.emit('[success] %s: %s' % (_("Converted units to"), new_units))
else:
- # Undo toggling
- self.toggle_units_ignore = True
- if self.defaults['units'].upper() == 'MM':
- self.ui.general_pref_form.general_app_group.units_radio.set_value('IN')
- else:
- self.ui.general_pref_form.general_app_group.units_radio.set_value('MM')
- self.toggle_units_ignore = False
+ factor = 1
# store the grid values so they are not changed in the next step
val_x = float(self.defaults['global_gridx'])
@@ -4875,14 +4859,14 @@ class App(QtCore.QObject):
self.preferencesUiManager.defaults_read_form()
- # the self.preferencesUiManager.defaults_read_form() will update all defaults values
- # in self.defaults from the GUI elements but
- # I don't want it for the grid values, so I update them here
+ # update the Grid snap values
self.defaults['global_gridx'] = val_x
self.defaults['global_gridy'] = val_y
self.ui.grid_gap_x_entry.set_value(val_x, decimals=self.decimals)
self.ui.grid_gap_y_entry.set_value(val_y, decimals=self.decimals)
+ return new_units, factor
+
def on_deselect_all(self):
self.collection.set_all_inactive()
self.delete_selection_shape()
@@ -5615,17 +5599,8 @@ class App(QtCore.QObject):
# Set the relative position label
dx = location[0] - float(self.rel_point1[0])
dy = location[1] - float(self.rel_point1[1])
- # self.ui.position_label.setText(" X: %.4f "
- # "Y: %.4f " % (location[0], location[1]))
- # # Set the position label
- # self.ui.rel_position_label.setText("Dx: %.4f Dy: "
- # "%.4f " % (dx, dy))
- self.ui.update_location_labels(dx, dy, location[0], location[1])
- # units = self.defaults["units"].lower()
- # self.plotcanvas.text_hud.text = \
- # 'Dx:\t{:<.4f} [{:s}]\nDy:\t{:<.4f} [{:s}]\n\nX: \t{:<.4f} [{:s}]\nY: \t{:<.4f} [{:s}]'.format(
- # dx, units, dy, units, location[0], units, location[1], units)
+ self.ui.update_location_labels(dx, dy, location[0], location[1])
self.plotcanvas.on_update_text_hud(dx, dy, location[0], location[1])
self.inform.emit('[success] %s' % _("Done."))
diff --git a/defaults.py b/defaults.py
index adc4f72a..85674c4d 100644
--- a/defaults.py
+++ b/defaults.py
@@ -24,6 +24,7 @@ class FlatCAMDefaults:
factory_defaults = {
# Global
+ "units": "MM",
"version": 8.992, # defaults format version, not necessarily equal to app version
"first_run": True,
"root_folder_path": '',
@@ -78,7 +79,6 @@ class FlatCAMDefaults:
"global_tcl_path": '',
# General APP Preferences
- "units": "MM",
"decimals_inch": 4,
"decimals_metric": 4,
"global_graphic_engine": '3D',