The wrapper allows to call resetTrackers in the main module after the callback to the GuiTools is executed.
This is the last commit, many thanks to @matthijskooijman for having menthored me :)
I think it's helpful to have @matthijskooijman explanation on this use of the wrapper:
This defines a new wrapper function, that calls the original callback and then calls resetTrackers. Note that this creates a new function for every loop iteration, so each of these wrapper functions captures potentially different callback, self and obj values so things work as expected. Note I did something weird with the callback value there: Since functions like these capture a variable, not its value at the time of function definition, and loop variables like label and callback are a single variable shared between all loop iterations, capturing callback directly ends up with all wrappers calling the last callback (i.e. they all capture the same variable and by the time the wrappers are called, that variable will contain the last of the callbacks). This is commonly solved by using a default value in the function definition, since such a default value uses the value of the (in this case) callback variable, not capturing the variable.
get_edit_point_context_menu(self, edit_command, obj, node_idx)
get_edit_obj_context_menu(self, edit_command, obj, position)
that are called depending if the user is over an editpoint or over another part of the object.
This enable to start editing also without an user click event, by just calling the method and specifying the object and the edit point index.
It is used for alternative edit mode (alt_edit_mode) by arc context menu
The code that was intended to handle this preference looked inside
Mod/BIM instad of Mod/Draft for the preference. This seems to have been
broken since the preference was first introduced in commit 9976a5ece0
(Draft: Turned autogroup button into layers selector (added pref option
to restore old groups-based system)).
This also removes a stray "-" that was probably a leftover from a merge
conflict, introduced in commit 0547d23660 (Draft: move Draft_AutoGroup to
gui_groups module). Since -True is still true and -False is still false,
this did not actually break the code, though.
See https://forum.freecadweb.org/viewtopic.php?t=42018 for related
discussion.
LGTM identified an instance where a function was defined twice: in this
case, one version was intended to take a list of items and the second
version just a single item. Because they share the same name and number
of arguments, the second definition overrode the first. This causes no
problems in the current code because the version that takes a list is
never used. However, for consistency with the analogous
"globalize_vectors" and "globalize_vector" functions, the "localize*"
versions are changed to match that pattern. All calls in are
converted to the singular use.
LGTM is concerned about the unused loop variable in this algorithm.
While there was nothing wrong here, to eliminate the alarm the loop was
removed entirely, since Python allows the use of the multiplication
operator here to achieve the same effect.
LGTM objected to the re-use of the loop variable a in the algorithm.
Upon closer inspection, the algorithm in this function could be modified
to match the algorithm in sync_snap_statusbar_button (which does the
same thing to the statusbar that this does to the toolbar). This
eliminates the double-use. This change does not affect the functionality
of the routine.
The code would only find a center snap on the face with index=0 of solids.
In V0.19 Part.getShape was introduced (line 399). But not all consequences were not fully implemented.
In the '# we are snapping to an edge' section (line 411) the code could be cleaned up. There is no need to check if the index of the edge is correct for the parent object since we are no longer dealing with a parent object. That portion was effectively dead code.
The '# we are snapping to a face' section (line 429 in the revised code) has been modified accordingly, which fixes the bug.
Forum discussion:
https://forum.freecadweb.org/viewtopic.php?f=23&t=54747