Looking at the surrounding code, this should be `==` rather than `in`.
The code does work as intended, because a string is always a substring
of itself, but better to fix it anyway.
Seems this was broken since this code was first introduced in commit
193339991f (Draft: clean up ViewProviderLabel class)
The "Merge layer duplicates" Tree view context menu option for LayerContainers did not work.
Additionally:
- Using `openTransaction` and `commitTransaction` is required for the `merge_by_name` function but also for the `add_layer` function. Otherwise undo-redo does not work properly.
- Have replaced `translate("Draft", ...)` with `_tr(...)`.
The "Transform" and "Set Colors..." context menu items did not work on
most Draft objects because the View Provider has a setEdit() function,
which overrides any edit action provided at a higher level (e.g. by
Part). This commit checks the mode of the edit, and if it is not zero,
behaves as though the setEdit() function does not exist, allowing Part
to provide the required context menu behavior.
When creating arrays of colors, the color information is often created
to be the same length as some array of objects. In three instances this
was achieved with a loop over that list of objects, even though the
objects themselves are never used. This commit eliminates those loops
and creates the required number of color instances directly.
Identified by LGTM.
It takes a `Shape` and replicates it around a path, while at the
same time adding a rotation to each copy. This can be used to create
a twisted "ribcage" from a frame-like object, which can be used
in a more complicated `Shape`, for example, a tunnel or bridge
object.
Move `make_layer` to `draftmake`; `Layer` and `LayerContainer`
to `draftobjects`; `ViewProviderLayer` and `ViewProviderLayerContainer`
to `draftviewproviders`.
The make function and the classes are imported in `Draft.py`
to support the usage of the older `VisGroup`.
This includes `view_array`, `view_base`, `view_bezcurve`,
`view_bspline`, `view_circulararray`, `view_clone`, `view_dimension`,
`view_draft_annotation`, `view_draftlink`, `view_facebinder`,
`view_fillet`, `view_label`, `view_orthoarray`, `view_point`,
`view_polararray`, `view_rectangle`, `view_text`, `view_wire`,
`view_wpproxy`.
These are added to the `draftviewproviders` Doxygen group
so that the functions and classes contained in each module
are listed appropriately in the automatically generated
documentation.
These functions were previously in `draftutils.utils`,
and are related to grouping objects and finding objects
inside groups. These include `get_group_names`, `ungroup`,
`get_windows`, `get_group_contents`, `get_movable_children`.
These are imported in the main `Draft.py` module, so compatibility
is retained.
Modules which use these functions are updated; these include
Gui Commands like `Move`, `Rotate`, `Scale`, `AddToGroup`,
as well as objects like `DrawingView` and `Shape2DView`,
and `ViewProviderClone`.
The code inside the `importDXF` module is also updated.
The Arch Workbench uses many of these functions
but it does so from the `Draft` namespace, so these edits
don't change the situation for these commands.
This class is also derived on `ViewProviderDimensionBase`.
It is used to measure the angle between two straight lines.
Various improvements in style, PEP8, spacing, docstrings.
In particular use more readable variable names.
The `updateData` method is modified to return immediately
if the `arc` attribute does not exist. This is better
to reduce the level of indentation of the code.