- fixed the toggle_units() method so now the grid values are accurate to the decimal
This commit is contained in:
@@ -2454,7 +2454,7 @@ class App(QtCore.QObject):
|
|||||||
# #####################################################################################
|
# #####################################################################################
|
||||||
|
|
||||||
# hold the App units
|
# hold the App units
|
||||||
self.units = 'IN'
|
self.units = 'MM'
|
||||||
|
|
||||||
# coordinates for relative position display
|
# coordinates for relative position display
|
||||||
self.rel_point1 = (0, 0)
|
self.rel_point1 = (0, 0)
|
||||||
@@ -4129,8 +4129,7 @@ class App(QtCore.QObject):
|
|||||||
# Check units and convert if necessary
|
# Check units and convert if necessary
|
||||||
# This condition CAN be true because initialize() can change obj.units
|
# This condition CAN be true because initialize() can change obj.units
|
||||||
if self.options["units"].upper() != obj.units.upper():
|
if self.options["units"].upper() != obj.units.upper():
|
||||||
self.inform.emit('%s: %s' %
|
self.inform.emit('%s: %s' % (_("Converting units to "), self.options["units"]))
|
||||||
(_("Converting units to "), self.options["units"]))
|
|
||||||
obj.convert_units(self.options["units"])
|
obj.convert_units(self.options["units"])
|
||||||
t3 = time.time()
|
t3 = time.time()
|
||||||
self.log.debug("%f seconds converting units." % (t3 - t2))
|
self.log.debug("%f seconds converting units." % (t3 - t2))
|
||||||
@@ -5609,6 +5608,22 @@ class App(QtCore.QObject):
|
|||||||
"""
|
"""
|
||||||
self.ui.units_label.setText("[" + units.lower() + "]")
|
self.ui.units_label.setText("[" + units.lower() + "]")
|
||||||
|
|
||||||
|
def on_toggle_units_click(self):
|
||||||
|
try:
|
||||||
|
self.ui.general_defaults_form.general_app_group.units_radio.activated_custom.disconnect()
|
||||||
|
except (TypeError, AttributeError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
if self.defaults["units"] == 'MM':
|
||||||
|
self.ui.general_defaults_form.general_app_group.units_radio.set_value("IN")
|
||||||
|
else:
|
||||||
|
self.ui.general_defaults_form.general_app_group.units_radio.set_value("MM")
|
||||||
|
|
||||||
|
self.on_toggle_units(no_pref=True)
|
||||||
|
|
||||||
|
self.ui.general_defaults_form.general_app_group.units_radio.activated_custom.connect(
|
||||||
|
lambda: self.on_toggle_units(no_pref=False))
|
||||||
|
|
||||||
def on_toggle_units(self, no_pref=False):
|
def on_toggle_units(self, no_pref=False):
|
||||||
"""
|
"""
|
||||||
Callback for the Units radio-button change in the Preferences tab.
|
Callback for the Units radio-button change in the Preferences tab.
|
||||||
@@ -5761,16 +5776,15 @@ class App(QtCore.QObject):
|
|||||||
self.defaults[dim] = val
|
self.defaults[dim] = val
|
||||||
|
|
||||||
# The scaling factor depending on choice of units.
|
# The scaling factor depending on choice of units.
|
||||||
|
|
||||||
factor = 25.4 if new_units == 'MM' else 1/25.4
|
factor = 25.4 if new_units == 'MM' else 1/25.4
|
||||||
|
|
||||||
# Changing project units. Warn user.
|
# Changing project units. Warn user.
|
||||||
msgbox = QtWidgets.QMessageBox()
|
msgbox = QtWidgets.QMessageBox()
|
||||||
msgbox.setWindowTitle(_("Toggle Units"))
|
msgbox.setWindowTitle(_("Toggle Units"))
|
||||||
msgbox.setWindowIcon(QtGui.QIcon('share/toggle_units32.png'))
|
msgbox.setWindowIcon(QtGui.QIcon('share/toggle_units32.png'))
|
||||||
msgbox.setText("<B>%s</B>" % _("Change project units ..."))
|
msgbox.setText(_("Changing the units of the project\n"
|
||||||
msgbox.setInformativeText(_("Changing the units of the project causes all geometrical "
|
"will scale all objects.\n\n"
|
||||||
"properties of all objects to be scaled accordingly.\nContinue?"))
|
"Do you want to continue?"))
|
||||||
bt_ok = msgbox.addButton(_('Ok'), QtWidgets.QMessageBox.AcceptRole)
|
bt_ok = msgbox.addButton(_('Ok'), QtWidgets.QMessageBox.AcceptRole)
|
||||||
msgbox.addButton(_('Cancel'), QtWidgets.QMessageBox.RejectRole)
|
msgbox.addButton(_('Cancel'), QtWidgets.QMessageBox.RejectRole)
|
||||||
|
|
||||||
@@ -5786,28 +5800,25 @@ class App(QtCore.QObject):
|
|||||||
|
|
||||||
self.defaults["units"] = new_units
|
self.defaults["units"] = new_units
|
||||||
|
|
||||||
# save the defaults to file, some may assume that the conversion is enough and it's not
|
# update the defaults from form, some may assume that the conversion is enough and it's not
|
||||||
self.on_save_button(save_to_file=True)
|
self.on_options_app2project()
|
||||||
|
|
||||||
self.should_we_save = True
|
# update the objects
|
||||||
|
for obj in self.collection.get_list():
|
||||||
|
obj.convert_units(new_units)
|
||||||
|
|
||||||
|
# make that the properties stored in the object are also updated
|
||||||
|
self.object_changed.emit(obj)
|
||||||
|
# rebuild the object UI
|
||||||
|
obj.build_ui()
|
||||||
|
|
||||||
# change this only if the workspace is active
|
# change this only if the workspace is active
|
||||||
if self.defaults['global_workspace'] is True:
|
if self.defaults['global_workspace'] is True:
|
||||||
self.plotcanvas.draw_workspace(pagesize=self.defaults['global_workspaceT'])
|
self.plotcanvas.draw_workspace(pagesize=self.defaults['global_workspaceT'])
|
||||||
|
|
||||||
# adjust the grid values on the main toolbar
|
# adjust the grid values on the main toolbar
|
||||||
val_x = float(self.ui.grid_gap_x_entry.get_value()) * factor
|
val_x = float(self.defaults['global_gridx']) * factor
|
||||||
self.ui.grid_gap_x_entry.set_value(val_x, decimals=self.decimals)
|
val_y = val_x if self.ui.grid_gap_link_cb.isChecked() else float(self.defaults['global_gridx']) * factor
|
||||||
if not self.ui.grid_gap_link_cb.isChecked():
|
|
||||||
val_y = float(self.ui.grid_gap_y_entry.get_value()) * factor
|
|
||||||
self.ui.grid_gap_y_entry.set_value(val_y, decimals=self.decimals)
|
|
||||||
|
|
||||||
for obj in self.collection.get_list():
|
|
||||||
obj.convert_units(new_units)
|
|
||||||
|
|
||||||
# make that the properties stored in the object are also updated
|
|
||||||
self.object_changed.emit(obj)
|
|
||||||
obj.build_ui()
|
|
||||||
|
|
||||||
current = self.collection.get_active()
|
current = self.collection.get_active()
|
||||||
if current is not None:
|
if current is not None:
|
||||||
@@ -5815,10 +5826,15 @@ class App(QtCore.QObject):
|
|||||||
if not isinstance(current, FlatCAMGeometry):
|
if not isinstance(current, FlatCAMGeometry):
|
||||||
current.to_form()
|
current.to_form()
|
||||||
|
|
||||||
|
# replot all objects
|
||||||
self.plot_all()
|
self.plot_all()
|
||||||
self.inform.emit('[success] %s: %s' % (_("Converted units to"), new_units))
|
# set the status labels to reflect the current FlatCAM units
|
||||||
# self.ui.units_label.setText("[" + self.options["units"] + "]")
|
|
||||||
self.set_screen_units(new_units)
|
self.set_screen_units(new_units)
|
||||||
|
|
||||||
|
# signal to the app that we changed the object properties and it shoud save the project
|
||||||
|
self.should_we_save = True
|
||||||
|
|
||||||
|
self.inform.emit('[success] %s: %s' % (_("Converted units to"), new_units))
|
||||||
else:
|
else:
|
||||||
# Undo toggling
|
# Undo toggling
|
||||||
self.toggle_units_ignore = True
|
self.toggle_units_ignore = True
|
||||||
@@ -5827,25 +5843,21 @@ class App(QtCore.QObject):
|
|||||||
else:
|
else:
|
||||||
self.ui.general_defaults_form.general_app_group.units_radio.set_value('MM')
|
self.ui.general_defaults_form.general_app_group.units_radio.set_value('MM')
|
||||||
self.toggle_units_ignore = False
|
self.toggle_units_ignore = False
|
||||||
self.inform.emit('[WARNING_NOTCL]%s' % _(" Units conversion cancelled."))
|
|
||||||
|
# store the grid values so they are not changed in the next step
|
||||||
|
val_x = float(self.defaults['global_gridx'])
|
||||||
|
val_y = float(self.defaults['global_gridy'])
|
||||||
|
|
||||||
|
self.inform.emit('[WARNING_NOTCL]%s' % _("Units conversion cancelled."))
|
||||||
|
|
||||||
self.defaults_read_form()
|
self.defaults_read_form()
|
||||||
|
|
||||||
def on_toggle_units_click(self):
|
# the self.defaults_read_form() will update all defaults values in self.defaults from the GUI elements but
|
||||||
try:
|
# I don't want it for the grid values, so I update them here
|
||||||
self.ui.general_defaults_form.general_app_group.units_radio.activated_custom.disconnect()
|
self.defaults['global_gridx'] = val_x
|
||||||
except (TypeError, AttributeError):
|
self.defaults['global_gridy'] = val_y
|
||||||
pass
|
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)
|
||||||
if self.defaults["units"] == 'MM':
|
|
||||||
self.ui.general_defaults_form.general_app_group.units_radio.set_value("IN")
|
|
||||||
else:
|
|
||||||
self.ui.general_defaults_form.general_app_group.units_radio.set_value("MM")
|
|
||||||
|
|
||||||
self.on_toggle_units(no_pref=True)
|
|
||||||
|
|
||||||
self.ui.general_defaults_form.general_app_group.units_radio.activated_custom.connect(
|
|
||||||
lambda: self.on_toggle_units(no_pref=False))
|
|
||||||
|
|
||||||
def on_fullscreen(self, disable=False):
|
def on_fullscreen(self, disable=False):
|
||||||
self.report_usage("on_fullscreen()")
|
self.report_usage("on_fullscreen()")
|
||||||
|
|||||||
@@ -9,6 +9,10 @@ CAD program, and create G-Code for Isolation routing.
|
|||||||
|
|
||||||
=================================================
|
=================================================
|
||||||
|
|
||||||
|
6.12.2019
|
||||||
|
|
||||||
|
- fixed the toggle_units() method so now the grid values are accurate to the decimal
|
||||||
|
|
||||||
5.12.2019
|
5.12.2019
|
||||||
|
|
||||||
- in NCC Tool, the new Geometry object that is created on copper clear now has the solid_geometry attribute where the geometry is stored not only in the obj.tools attribute
|
- in NCC Tool, the new Geometry object that is created on copper clear now has the solid_geometry attribute where the geometry is stored not only in the obj.tools attribute
|
||||||
|
|||||||
Reference in New Issue
Block a user