Skip to content

Commit e559e3e

Browse files
authored
Merge pull request #3472 from Sigma1912/Gmoccapy_Use_calculator_to_change_values_in_tooltable
Gmoccapy: Use calculator widget to edit numeric values in tooltable
2 parents 77dd339 + 0713d08 commit e559e3e

1 file changed

Lines changed: 42 additions & 4 deletions

File tree

src/emc/usr_intf/gmoccapy/gmoccapy.py

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ def __init__(self, argv):
212212
self.incr_rbt_list = [] # we use this list to add hal pin to the button later
213213
self.jog_increments = [] # This holds the increment values
214214
self.unlock = False # this value will be set using the hal pin unlock settings
215+
self.toolpage_use_calc = True # enable/disable calculator widget to edit numeric values in the tool editor
215216

216217
# needed to display the labels
217218
self.system_list = ("0", "G54", "G55", "G56", "G57", "G58", "G59", "G59.1", "G59.2", "G59.3")
@@ -1943,7 +1944,6 @@ def set_up_user_tab_widgets(self, tab_locations):
19431944

19441945
# and we load the tooltable data
19451946
def _init_tooleditor(self):
1946-
19471947
# get the path to the tool table
19481948
tooltable = self.get_ini_info.get_toolfile()
19491949
if not tooltable:
@@ -1953,20 +1953,58 @@ def _init_tooleditor(self):
19531953
sys.exit()
19541954
toolfile = os.path.join(CONFIGPATH, tooltable)
19551955
self.widgets.tooledit1.set_filename(toolfile)
1956-
19571956
# first we hide all the axis columns the unhide the ones we want
19581957
self.widgets.tooledit1.set_visible("abcxyzuvwijq", False)
19591958
for axis in self.axis_list:
19601959
self.widgets.tooledit1.set_visible("{0}".format(axis), True)
1961-
19621960
# if it's a lathe config we show lathe related columns
19631961
if self.lathe_mode:
19641962
self.widgets.tooledit1.set_visible("ijq", True)
19651963
if not self.get_ini_info.get_lathe_wear_offsets():
19661964
# hide the wear offset tabs
19671965
self.widgets.tooledit1.set_lathe_display(False)
1968-
19691966
self.widgets.tooledit1.hide_buttonbox(True)
1967+
column_cell_ids = ["toggle", "tool#1", "pos1", "x1", "y1", "z1", "a1", "b1", "c1", "u1", "v1", "w1",
1968+
"d1", "front1", "back1", "orient1", "cell_comments1"]
1969+
for col, name in enumerate(column_cell_ids):
1970+
if col > 0 and col < 16:
1971+
temp = self.widgets.tooledit1.wTree.get_object("cell_%s" % name)
1972+
temp.connect('editing-started', self.on_tool_col_edit_started, col)
1973+
1974+
def on_tool_col_edit_started(self, widget, filtered_path, new_text, col):
1975+
if not self.toolpage_use_calc:
1976+
return
1977+
captations = ["toggle", "Tool#", "Pocket",
1978+
"X-offset", "Y-offset", "Z-offset",
1979+
"A-offset", "B-offset", "C-offset",
1980+
"U-offset", "V-offset", "W-offset",
1981+
"Diameter", "Front angle", "Back angle", "Orientation", ";1"]
1982+
toolpage = self.widgets.tooledit1
1983+
toolview = toolpage.view1
1984+
model, row = toolview.get_selection().get_selected()
1985+
value = self.dialogs.entry_dialog(self,
1986+
data=model[row][col],
1987+
header=_("Enter value"),
1988+
label=_("Tool %s, %s:" % (model[row][1], captations[col])),
1989+
integer=col in [1,2,15])
1990+
if value == "ERROR":
1991+
LOG.debug("conversion error")
1992+
self.dialogs.warning_dialog(self, _("Conversion error !"),
1993+
("Please enter only numerical values\nValues have not been applied"))
1994+
elif value == "CANCEL":
1995+
pass
1996+
else:
1997+
store = toolpage.wTree.get_object("liststore1")
1998+
if col in [1,2,15]:
1999+
store[row][col] = value
2000+
else:
2001+
store[row][col] = locale.format_string("%11.4f", value)
2002+
# this is needed to get offsetview out of editing mode
2003+
GLib.timeout_add(50,
2004+
toolview.set_cursor,
2005+
toolpage.model.get_path(row),
2006+
toolview.get_columns()[0],
2007+
True)
19702008

19712009
def _init_themes(self):
19722010
# If there are themes then add them to combo box

0 commit comments

Comments
 (0)