- application wide change: introduced the precision parameters in Edit -> Preferences who will control how many decimals to use in the app parameters
This commit is contained in:
@@ -32,10 +32,12 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
|
||||
geom_update = QtCore.pyqtSignal(int, int, int, int, int, name='geomUpdate')
|
||||
final_save = QtCore.pyqtSignal(name='saveBeforeExit')
|
||||
|
||||
def __init__(self, version, beta, app):
|
||||
def __init__(self, app):
|
||||
super(FlatCAMGUI, self).__init__()
|
||||
|
||||
self.app = app
|
||||
self.decimals = self.app.decimals
|
||||
|
||||
# Divine icon pack by Ipapun @ finicons.com
|
||||
|
||||
# ################################## ##
|
||||
@@ -2002,8 +2004,8 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
|
||||
|
||||
self.setGeometry(100, 100, 1024, 650)
|
||||
self.setWindowTitle('FlatCAM %s %s - %s' %
|
||||
(version,
|
||||
('BETA' if beta else ''),
|
||||
(self.app.version,
|
||||
('BETA' if self.app.beta else ''),
|
||||
platform.architecture()[0])
|
||||
)
|
||||
|
||||
@@ -2024,14 +2026,14 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
|
||||
self.grb_editor_cmenu.menuAction().setVisible(False)
|
||||
self.e_editor_cmenu.menuAction().setVisible(False)
|
||||
|
||||
self.general_defaults_form = GeneralPreferencesUI()
|
||||
self.gerber_defaults_form = GerberPreferencesUI()
|
||||
self.excellon_defaults_form = ExcellonPreferencesUI()
|
||||
self.geometry_defaults_form = GeometryPreferencesUI()
|
||||
self.cncjob_defaults_form = CNCJobPreferencesUI()
|
||||
self.tools_defaults_form = ToolsPreferencesUI()
|
||||
self.tools2_defaults_form = Tools2PreferencesUI()
|
||||
self.util_defaults_form = UtilPreferencesUI()
|
||||
self.general_defaults_form = GeneralPreferencesUI(decimals=self.decimals)
|
||||
self.gerber_defaults_form = GerberPreferencesUI(decimals=self.decimals)
|
||||
self.excellon_defaults_form = ExcellonPreferencesUI(decimals=self.decimals)
|
||||
self.geometry_defaults_form = GeometryPreferencesUI(decimals=self.decimals)
|
||||
self.cncjob_defaults_form = CNCJobPreferencesUI(decimals=self.decimals)
|
||||
self.tools_defaults_form = ToolsPreferencesUI(decimals=self.decimals)
|
||||
self.tools2_defaults_form = Tools2PreferencesUI(decimals=self.decimals)
|
||||
self.util_defaults_form = UtilPreferencesUI(decimals=self.decimals)
|
||||
|
||||
QtWidgets.qApp.installEventFilter(self)
|
||||
|
||||
@@ -3471,16 +3473,12 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
|
||||
val, ok = tool_add_popup.get_value()
|
||||
if ok:
|
||||
self.app.exc_editor.on_tool_add(tooldia=val)
|
||||
formated_val = '%.4f' % float(val)
|
||||
self.app.inform.emit('[success] %s: %s %s' %
|
||||
(_("Added new tool with dia"),
|
||||
formated_val,
|
||||
str(self.units)
|
||||
)
|
||||
)
|
||||
else:
|
||||
formated_val = '%.*f' % (self.decimals, float(val))
|
||||
self.app.inform.emit(
|
||||
'[WARNING_NOTCL] %s' % _("Adding Tool cancelled ..."))
|
||||
'[success] %s: %s %s' % (_("Added new tool with dia"), formated_val, str(self.units))
|
||||
)
|
||||
else:
|
||||
self.app.inform.emit('[WARNING_NOTCL] %s' % _("Adding Tool cancelled ..."))
|
||||
return
|
||||
|
||||
# Zoom Fit
|
||||
|
||||
@@ -145,7 +145,7 @@ class RadioSet(QtWidgets.QWidget):
|
||||
|
||||
|
||||
class LengthEntry(QtWidgets.QLineEdit):
|
||||
def __init__(self, output_units='IN', parent=None):
|
||||
def __init__(self, output_units='IN', decimals=None, parent=None):
|
||||
super(LengthEntry, self).__init__(parent)
|
||||
|
||||
self.output_units = output_units
|
||||
@@ -160,6 +160,7 @@ class LengthEntry(QtWidgets.QLineEdit):
|
||||
}
|
||||
self.readyToEdit = True
|
||||
self.editingFinished.connect(self.on_edit_finished)
|
||||
self.decimals = decimals if decimals is not None else 4
|
||||
|
||||
def on_edit_finished(self):
|
||||
self.clearFocus()
|
||||
@@ -203,8 +204,9 @@ class LengthEntry(QtWidgets.QLineEdit):
|
||||
log.warning("Could not parse value in entry: %s" % str(raw))
|
||||
return None
|
||||
|
||||
def set_value(self, val):
|
||||
self.setText(str('%.4f' % val))
|
||||
def set_value(self, val, decimals=None):
|
||||
dec_digits = decimals if decimals is not None else self.decimals
|
||||
self.setText(str('%.*f' % (dec_digits, val)))
|
||||
|
||||
def sizeHint(self):
|
||||
default_hint_size = super(LengthEntry, self).sizeHint()
|
||||
@@ -212,10 +214,11 @@ class LengthEntry(QtWidgets.QLineEdit):
|
||||
|
||||
|
||||
class FloatEntry(QtWidgets.QLineEdit):
|
||||
def __init__(self, parent=None):
|
||||
def __init__(self, decimals=None, parent=None):
|
||||
super(FloatEntry, self).__init__(parent)
|
||||
self.readyToEdit = True
|
||||
self.editingFinished.connect(self.on_edit_finished)
|
||||
self.decimals = decimals if decimals is not None else 4
|
||||
|
||||
def on_edit_finished(self):
|
||||
self.clearFocus()
|
||||
@@ -251,9 +254,10 @@ class FloatEntry(QtWidgets.QLineEdit):
|
||||
log.error("Could not evaluate val: %s, error: %s" % (str(raw), str(e)))
|
||||
return None
|
||||
|
||||
def set_value(self, val):
|
||||
def set_value(self, val, decimals=None):
|
||||
dig_digits = decimals if decimals is not None else self.decimals
|
||||
if val is not None:
|
||||
self.setText("%.4f" % float(val))
|
||||
self.setText("%.*f" % (dig_digits, float(val)))
|
||||
else:
|
||||
self.setText("")
|
||||
|
||||
@@ -263,10 +267,11 @@ class FloatEntry(QtWidgets.QLineEdit):
|
||||
|
||||
|
||||
class FloatEntry2(QtWidgets.QLineEdit):
|
||||
def __init__(self, parent=None):
|
||||
def __init__(self, decimals=None, parent=None):
|
||||
super(FloatEntry2, self).__init__(parent)
|
||||
self.readyToEdit = True
|
||||
self.editingFinished.connect(self.on_edit_finished)
|
||||
self.decimals = decimals if decimals is not None else 4
|
||||
|
||||
def on_edit_finished(self):
|
||||
self.clearFocus()
|
||||
@@ -295,8 +300,9 @@ class FloatEntry2(QtWidgets.QLineEdit):
|
||||
log.error("Could not evaluate val: %s, error: %s" % (str(raw), str(e)))
|
||||
return None
|
||||
|
||||
def set_value(self, val):
|
||||
self.setText("%.4f" % val)
|
||||
def set_value(self, val, decimals=None):
|
||||
dig_digits = decimals if decimals is not None else self.decimals
|
||||
self.setText("%.*f" % (dig_digits, val))
|
||||
|
||||
def sizeHint(self):
|
||||
default_hint_size = super(FloatEntry2, self).sizeHint()
|
||||
|
||||
@@ -35,10 +35,11 @@ class ObjectUI(QtWidgets.QWidget):
|
||||
put UI elements in ObjectUI.custom_box (QtWidgets.QLayout).
|
||||
"""
|
||||
|
||||
def __init__(self, icon_file='share/flatcam_icon32.png', title=_('FlatCAM Object'), parent=None, common=True):
|
||||
def __init__(self, icon_file='share/flatcam_icon32.png', title=_('FlatCAM Object'), parent=None, common=True,
|
||||
decimals=4):
|
||||
QtWidgets.QWidget.__init__(self, parent=parent)
|
||||
|
||||
self.decimals = 4
|
||||
self.decimals = decimals
|
||||
|
||||
layout = QtWidgets.QVBoxLayout()
|
||||
self.setLayout(layout)
|
||||
@@ -153,9 +154,9 @@ class GerberObjectUI(ObjectUI):
|
||||
User interface for Gerber objects.
|
||||
"""
|
||||
|
||||
def __init__(self, parent=None):
|
||||
ObjectUI.__init__(self, title=_('Gerber Object'), parent=parent)
|
||||
self.decimals = 4
|
||||
def __init__(self, decimals, parent=None):
|
||||
ObjectUI.__init__(self, title=_('Gerber Object'), parent=parent, decimals=decimals)
|
||||
self.decimals = decimals
|
||||
|
||||
# Plot options
|
||||
grid0 = QtWidgets.QGridLayout()
|
||||
@@ -669,12 +670,13 @@ class ExcellonObjectUI(ObjectUI):
|
||||
User interface for Excellon objects.
|
||||
"""
|
||||
|
||||
def __init__(self, parent=None):
|
||||
def __init__(self, decimals, parent=None):
|
||||
ObjectUI.__init__(self, title=_('Excellon Object'),
|
||||
icon_file='share/drill32.png',
|
||||
parent=parent)
|
||||
parent=parent,
|
||||
decimals=decimals)
|
||||
|
||||
self.decimals = 4
|
||||
self.decimals = decimals
|
||||
|
||||
# ### Plot options ####
|
||||
hlay_plot = QtWidgets.QHBoxLayout()
|
||||
@@ -1072,10 +1074,10 @@ class GeometryObjectUI(ObjectUI):
|
||||
User interface for Geometry objects.
|
||||
"""
|
||||
|
||||
def __init__(self, parent=None):
|
||||
def __init__(self, decimals, parent=None):
|
||||
super(GeometryObjectUI, self).__init__(title=_('Geometry Object'),
|
||||
icon_file='share/geometry32.png', parent=parent)
|
||||
self.decimals = 4
|
||||
icon_file='share/geometry32.png', parent=parent, decimals=decimals)
|
||||
self.decimals = decimals
|
||||
|
||||
# Plot options
|
||||
self.plot_options_label = QtWidgets.QLabel("<b>%s:</b>" % _("Plot Options"))
|
||||
@@ -1623,14 +1625,15 @@ class CNCObjectUI(ObjectUI):
|
||||
User interface for CNCJob objects.
|
||||
"""
|
||||
|
||||
def __init__(self, parent=None):
|
||||
def __init__(self, decimals, parent=None):
|
||||
"""
|
||||
Creates the user interface for CNCJob objects. GUI elements should
|
||||
be placed in ``self.custom_box`` to preserve the layout.
|
||||
"""
|
||||
|
||||
ObjectUI.__init__(self, title=_('CNC Job Object'), icon_file='share/cnc32.png', parent=parent)
|
||||
self.decimals = 4
|
||||
|
||||
ObjectUI.__init__(self, title=_('CNC Job Object'), icon_file='share/cnc32.png', parent=parent,
|
||||
decimals=decimals)
|
||||
self.decimals = decimals
|
||||
|
||||
for i in range(0, self.common_grid.count()):
|
||||
self.common_grid.itemAt(i).widget().hide()
|
||||
@@ -1932,7 +1935,7 @@ class ScriptObjectUI(ObjectUI):
|
||||
User interface for Script objects.
|
||||
"""
|
||||
|
||||
def __init__(self, parent=None):
|
||||
def __init__(self, decimals, parent=None):
|
||||
"""
|
||||
Creates the user interface for Script objects. GUI elements should
|
||||
be placed in ``self.custom_box`` to preserve the layout.
|
||||
@@ -1941,7 +1944,10 @@ class ScriptObjectUI(ObjectUI):
|
||||
ObjectUI.__init__(self, title=_('Script Object'),
|
||||
icon_file='share/script_new24.png',
|
||||
parent=parent,
|
||||
common=False)
|
||||
common=False,
|
||||
decimals=decimals)
|
||||
|
||||
self.decimals = decimals
|
||||
|
||||
# ## Object name
|
||||
self.name_hlay = QtWidgets.QHBoxLayout()
|
||||
@@ -1984,7 +1990,7 @@ class DocumentObjectUI(ObjectUI):
|
||||
User interface for Notes objects.
|
||||
"""
|
||||
|
||||
def __init__(self, parent=None):
|
||||
def __init__(self, decimals, parent=None):
|
||||
"""
|
||||
Creates the user interface for Notes objects. GUI elements should
|
||||
be placed in ``self.custom_box`` to preserve the layout.
|
||||
@@ -1993,7 +1999,10 @@ class DocumentObjectUI(ObjectUI):
|
||||
ObjectUI.__init__(self, title=_('Document Object'),
|
||||
icon_file='share/notes16_1.png',
|
||||
parent=parent,
|
||||
common=False)
|
||||
common=False,
|
||||
decimals=decimals)
|
||||
|
||||
self.decimals = decimals
|
||||
|
||||
# ## Object name
|
||||
self.name_hlay = QtWidgets.QHBoxLayout()
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user