From c0671b7754e326e24defeef0bbbd2b40e753ad19 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Sat, 24 Oct 2020 01:52:53 +0300 Subject: [PATCH] - minor changes --- CHANGELOG.md | 1 + appEditors/AppGeoEditor.py | 98 +++++++++++++++++++++----------------- 2 files changed, 54 insertions(+), 45 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 795c5b17..a4178793 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ CHANGELOG for FlatCAM beta - added a new GUI element, an InputDialog made out of FCSliderWithSpinner named FCInputDialogSlider - replaced the InputDialog in the Opacity pop menu for the objects in the Project Tab with a FCInputDialogSlider +- minor changes 23.10.2020 diff --git a/appEditors/AppGeoEditor.py b/appEditors/AppGeoEditor.py index 0c1a716f..66f98ced 100644 --- a/appEditors/AppGeoEditor.py +++ b/appEditors/AppGeoEditor.py @@ -3419,57 +3419,15 @@ class AppGeoEditor(QtCore.QObject): self.rtree_index = rtindex.Index() - def entry2option(opt, entry): - """ - - :param opt: A option from the self.options dictionary - :param entry: A GUI element which text value is used - :return: - """ - try: - text_value = entry.text() - if ',' in text_value: - text_value = text_value.replace(',', '.') - self.options[opt] = float(text_value) - except Exception as e: - entry.set_value(self.app.defaults[opt]) - log.debug("AppGeoEditor.__init__().entry2option() --> %s" % str(e)) - return - - def grid_changed(goption, gentry): - """ - - :param goption: String. Can be either 'global_gridx' or 'global_gridy' - :param gentry: A GUI element which text value is read and used - :return: - """ - if goption not in ['global_gridx', 'global_gridy']: - return - - entry2option(opt=goption, entry=gentry) - # if the grid link is checked copy the value in the GridX field to GridY - try: - text_value = gentry.text() - if ',' in text_value: - text_value = text_value.replace(',', '.') - val = float(text_value) - except ValueError: - return - - if self.app.ui.grid_gap_link_cb.isChecked(): - self.app.ui.grid_gap_y_entry.set_value(val, decimals=self.decimals) - self.app.ui.grid_gap_x_entry.setValidator(QtGui.QDoubleValidator()) - self.app.ui.grid_gap_x_entry.textChanged.connect( - lambda: grid_changed("global_gridx", self.app.ui.grid_gap_x_entry)) + self.app.ui.grid_gap_x_entry.textChanged.connect(self.on_gridx_val_changed) self.app.ui.grid_gap_y_entry.setValidator(QtGui.QDoubleValidator()) - self.app.ui.grid_gap_y_entry.textChanged.connect( - lambda: entry2option("global_gridy", self.app.ui.grid_gap_y_entry)) + self.app.ui.grid_gap_y_entry.textChanged.connect(self.on_gridy_val_changed) self.app.ui.snap_max_dist_entry.setValidator(QtGui.QDoubleValidator()) self.app.ui.snap_max_dist_entry.textChanged.connect( - lambda: entry2option("snap_max", self.app.ui.snap_max_dist_entry)) + lambda: self.entry2option("snap_max", self.app.ui.snap_max_dist_entry)) # if using Paint store here the tool diameter used self.paint_tooldia = None @@ -3522,6 +3480,56 @@ class AppGeoEditor(QtCore.QObject): self.delete_selected() self.replot() + def entry2option(self, opt, entry): + """ + + :param opt: A option from the self.options dictionary + :param entry: A GUI element which text value is used + :return: + """ + try: + text_value = entry.text() + if ',' in text_value: + text_value = text_value.replace(',', '.') + self.options[opt] = float(text_value) + except Exception as e: + entry.set_value(self.app.defaults[opt]) + log.debug("AppGeoEditor.__init__().entry2option() --> %s" % str(e)) + return + + def grid_changed(self, goption, gentry): + """ + + :param goption: String. Can be either 'global_gridx' or 'global_gridy' + :param gentry: A GUI element which text value is read and used + :return: + """ + if goption not in ['global_gridx', 'global_gridy']: + return + + self.entry2option(opt=goption, entry=gentry) + # if the grid link is checked copy the value in the GridX field to GridY + try: + text_value = gentry.text() + if ',' in text_value: + text_value = text_value.replace(',', '.') + val = float(text_value) + except ValueError: + return + + if self.app.ui.grid_gap_link_cb.isChecked(): + self.app.ui.grid_gap_y_entry.set_value(val, decimals=self.decimals) + + def on_gridx_val_changed(self): + self.grid_changed("global_gridx", self.app.ui.grid_gap_x_entry) + # try: + # self.app.defaults["global_gridx"] = float(self.app.ui.grid_gap_x_entry.get_value()) + # except ValueError: + # return + + def on_gridy_val_changed(self): + self.entry2option("global_gridy", self.app.ui.grid_gap_y_entry) + def set_ui(self): # updated units self.units = self.app.defaults['units'].upper()