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.
This class handles linear dimensions of edges, or radial
dimensions of arcs and circles.
Various improvements in style, PEP8, spacing, docstrings.
In particular use more readable variable names.
The modules `Part` and `DraftGeomUtils` have been delayed
in import.
The `updataData` method is modified to return immediately
if the Proxy property modified is different from `Start`,
`End`, `Dimline` or `Direction`.
Use methods to set up the properties. As the dimension object has
16 properties, these properties are assigned using three methods
corresponding to text, units, and graphics properties.
Various improvements in style, PEP8, spacing, docstrings.
Improve the methods to update the text, the arrow, and the frame
of the label.
Options to handle `Justification` and `LineSpacing` are added.
These can be handled just like with the `ViewProviderText` object,
as the internal text node is the same, a `SoAsciiText`.
Nevertheless, currently the leader line and the frame that are
drawn for the label don't consider the correction in position
for the `Justification` or `Linespacing` so the graphics
may be overlapped in certain situations.
Various improvements in style, PEP8, spacing, docstrings.
The list of strings is set to empty before being assigned again.
This solves a problem of the text not being updated correctly.
In the past some `try-except` blocks were there to catch and
ignore certain exceptions that apparently were caused by a
race condition, where certain properties are not assigned
to the object before they are used. These errors
don't seem to occur in v0.19, so we removed the exception
handling. We leave comments mentioning the issue
in case it re-appears.
The `DisplayMode` is swapped, so now `'2D text'` means that the
text always faces the camera, and `'3D text'` means that the
text can be positioned in different orientations in the 3D space.
This is consistent with the `Draft Label` behavior.
A function `draftutils.gui_utils.migrate_text_display_mode`
is provided to help migrate older objects of type `Text`
or `DraftText` to the new display mode.
The classes `ViewProviderDimensionBase`, `ViewProviderLinearDimension`,
`ViewProviderAngularDimension`, `ViewProviderText`, and
`ViewProviderLabel` use `super()` to call the `onChanged` method
of the parent class `ViewProviderDraftAnnotation`.
In this way the `AnnotationStyle` property correctly modifies
the properties of every annotation object.
Add view properties of dimensions, labels, and text objects
through methods, calling the parent classes, and `ViewProviderDraftAnnotation`
when needed.
This class is the base of the viewproviders of annotation-type
objects like dimensions (linear, radial, angular), labels,
and texts.
The basic properties of `ViewProviderDraftAnnotation`
are set up by a method `set_properties`, which can be called
in the derived classes.
In the general proxy object `DraftAnnotation` we implement
the `onDocumentRestored` method in order to add the missing
view property `AnnotationStyle` to older objects.
When the value of the `Text` is changed, in the Coin node
only the first element in the list of strings is updated,
the other elements remain the same, resulting in an incorrect
label.
So we empty the value of the Coin string with `setValue("")`,
and then we can assign the new string list, producing the correct
expected result.
Also perform several improvements such as PEP8 cleanup,
write complete docstring, type checking of the input arguments,
accepting a full placement to modify the position,
and deprecating the older call.
Update the Gui Command as well.
The original code was in `DraftFillet.py` which is split
into a different modules like the rest of the workbench.
The object code is in `draftobjects`, the viewprovider
is in `draftviewproviders`, and the function to create it
is in `draftmake`.
The improvements are done to `ViewProviderWire` which propagates
to many objects like Line, Wire (polyline), BSpline, BezCurve,
Fillet, etc.
The initialization of the properties is moved to a method
`_set_properties`. The properties `EndArrow`, `ArrowSize`,
`ArrowType` are created only if they do not exist.
This allows calling `ViewProviderWire(obj.ViewObject)`
to migrate an older object to this viewprovider
but without adding duplicated properties.
In particular, this is done to support the migration of the older
`Fillet` object.
The improvements are done to `ViewProviderDraft` which propagates
to the majority of the Draft objects by derived classes
like `ViewProviederWire`.
The initialization of the properties is moved to a method
`_set_properties`. The properties `Pattern` and `PatternSize`
are created only if they do not exist.
This allows calling `ViewProviderDraft(obj.ViewObject)`
to migrate an older object to this viewprovider
but without adding duplicated properties.
In particular, this is done to support the migration of the older
`Fillet` object.