* The new align_to_face_and_edge functions would align the Y axis to the edge. This should be the X axis.
* The align_to_point_and_axis functions did not accept a zero length upvec.
* Added a return value to the _next function for compatibilty with its counterpart the _previous function.
* BIM: Use checkbox in model tree for Activation/Deactivation of WP
* BIM: Set active object after deactivating current object if it exists
Currently we can get into a scenario where user can activate two working
planes, one after another. For example, Level, and then Level001. If
they activate both, and then deactivate Level001, working plane switches
back to Level. But, we didn't set the object as the active one, so user
didn't have clear information that they can deactivate it, only the
working plane was switching it.
So this patch sets the object as the active one, if it exists.
* BIM: Add support for deactivation active object to BIM Views Tree
As the title says - it adds the checkbox that's similarly done in Part
workbench, so user can select/deselect the item and if they had previous
active object, it will also fall back to the previous object.
Also, moved out part of the common logic from ArchBuildingPart and
BimViews to utils.
* BIM: Handle correct context on activating WP for NativeIFC/BIM
* BIM: Remove redundant logic from BIM Views upon double click
As all of the logic is being handled now in `activate` function in
BimViews, this logic is redundant
* BIM: Rename button for taskbar and BIM Views from Activate to Active
* Allow to align the working plane on selected edge + face of a same object, which aligns the plane with the face, but positions it on the edge (the WP is positioned on the edge's first vertex, the WP's X axis is aligned with the edge, and the face's center point provides the third point to define the plane)
* Added a "Recenter" in-command shortcut. This moves the WP to be centered on the current snap position (the WorkingPlane snap button is taken into account, so one can only move the WP in the same plane or not).
#14206 was an intermediate solution. Now that `Part.getShape` can handle the new `SubElementNames` it needs to be removed as it breaks the handling of subelements in links.
#14206 was an intermediate solution. Now that `Part.getShape` can handle the new `SubElementNames` it needs to be removed as it breaks the handling of subelements in links.
Related issue:
#5603.
The view observer starts/stops when the Draft workbench is activated/deactivated.
Additionally:
* Minor improvements to _update_grid and _update_gui.
Related issue:
#5603.
* The history idx value was not handled properly.
* Part.getShape() ignores the Placement of a selected BuildingPart. Have to use `place * obj.Placement`.
Related issue:
#5603.
* An 'auto' WP should not be added to the history if the previous WP in the history is also 'auto'.
* The `get_working_plane` function should only call `set_to_default` if the GUI is up. The axis of the returned WP should match global +Z if the GUI is not up.
Related issue:
#5603.
Previous PRs:
#10766#10838#10931
Short explanation:
* The PlaneGui class handles several GUI related aspects of the WP including a WP history.
* The `get_working_plane` function should be used to get a WP.
* Some of the code was taken from gui_selectplane.py. The intention is to remove almost all WP related code from that file. The icon, tooltip and label for the draftToolBar are also handled by PlaneGui.
* The tooltip shows extended information about the WP (position and axes vectors). An asteriks is appended to the label if the origin does not match the global origin.
* The `_update_all` function still updates FreeCAD.DraftWorkingPlane for compatibility.
* Some confusing names from the Plane class have been changed: `weak` -> `auto`, `reset` -> `set_to_auto`, `setup` -> `auto_align`.
Next step:
Implementing PlaneGui in Draft and Arch. The gui_selectplane.py file will be updated first.
Related issue:
#5603.
Previous PRs:
#10766#10838
The remaining Plane class functions have been processed (some are unchanged):
`setup`
* Updated to use new functions.
* The `direction` etc. arguments are never used AFAICT.
* Added `from draftutils import gui_utils`.
`reset`
* Unchanged.
`setTop`
* Calls `super().set_to_top()`. That function does not use `align_to_point_and_axis` but specifies exact vectors for improved accuracy.
* `import FreeCADGui` already happens at the top of the file.
* The code block after `if FreeCAD.GuiUp:` was kept for now.
`setFront`
* Idem.
`setSide`
* This function sets the WP to the left side position, and not to the right side postion as in the Draft_SelectPlane command.
* Idem.
`getRotation`
* Revised.
* The function has an akward name as it returns a Placement.
* The special code for Arch active container is obsolete (was already commented out in other functions).
`getPlacement`
* The `rotated argument` is ignored now. It was only used in the context of the old `placement_from_face` algorithm. See `DraftGeomUtils.placement_from_face` for the new implementation.
* Calls `super().get_placement()`.
`getNormal`
* Basically unchanged.
`setFromPlacement`
* Revised to call `super()` functions.
`inverse`
* Unchanged.
`save`
* Unchanged.
`restore`
* More compact code, but basically unchanged.
`getLocalCoords`
* Calls `super().get_local_coords()` which does not rely on Draft code, but creates a matrix and returns `mtx.inverse().multVec(point)`.
`getGlobalCoords`
* Calls `super().get_global_coords()` which creates a matrix and returns `mtx.multVec(point)`.
`getLocalRot`
* Calls `super().get_local_coords()`.
`getGlobalRot`
* Calls `super().get_global_coords()`.
`getClosestAxis`
* Calls `super().get_closest_axis(vec)` which translates the vector to the WP coordinate system and then finds the closest axis by comparing the absolute coordinates of the vector.
`isGlobal`
* Not used anywhere AFAICT.
* Calls `super().is_global()` which also checks the `position` attribute.
* As before the function works without any tolerance.
`isOrtho`
* Not used anywhere AFAICT.
* The original algorithm did not work properly (there was a comment). All angles were measured relative to the global Y axis. If the WP was randomly rotated around that axis the function would still return `True`. The new algorithm, `super().is_ortho()`, uses rounded Yaw, Pitch and Roll angles to check for orthogonality.
`getDeviation`
* Not used anywhere AFAICT.
* Unchanged.
`getParameters`
* Calls `super().get_parameters()` which uses the local `_get_prop_list` function.
`setFromParameters`
* Calls `super().set_parameters()` which uses the local `_get_prop_list` function.
`_get_prop_list`
* Function used internally. Returns a list of attribute.
After this PR the `Plane` class inherits from the `PlaneBase` class.
Related issue:
#5603.
Previous PR:
#10766
The following functions have been updated:
`__init__`
* `u` argument can be a WP now.
* Input vectors are copied.
* Added the `weak` argument.
* the `doc` attribute was not used and has been removed.
`__repr__`
* Inherited.
* The `position` is now also shown.
`copy`
* Uses `match` from the parent class which uses the local `_get_prop_list` function. Again vectors are copied.
`offsetToPoint`
* I could not find evidence that this function is used anywhere.
* The `direction` argument did not make a lot of sense (only worked in 2D). It is now ignored.
* Removed the overly long docstring.
* The function now uses an external function: `DraftGeomUtils.distance_to_plane`.
`projectPoint`
* The function calls `super().project_point` which in turn calls `DraftGeomUtils.project_point_on_plane`.
* `from sys import float_info` is no longer required.
`projectPointOld`
* Obsolete and removed.
`align*`
* All align* functions now have an `offset` argument.
* All align* functions return `True` or `False`.
`alignToPointAndAxis`
* The function ignored `upvec` if `axis` was parallel to the global X axis. This meant that the "Set WP" button of the Draft_Wire command did not work properly if the WP was aligned with the Right or Left view.
* The function calls `align_to_point_and_axis` which determines the rotation with `FreeCAD.Rotation(Vector(), upvec, axis, "ZYX")`.
`alignToPointAndAxis_SVG`
* The function calls `super().align_to_point_and_axis_svg` which contains the code from the old function.
`alignToCurve`
* Was not implemented.
`alignToEdges`
* Original code required two parallel edges (for example from an axis system), else the `u` and `v` vectors would not be perpendicular.
* The function calls `super().align_to_edges_vertexes` now.
`alignToFace`
* The function now uses an external function: `DraftGeomUtils.placement_from_face`. The rotation algorithm for the `u` and `v` vectors has been moved there.
`alignTo3Points`
* Basically unchanged. `Part` is already imported at the top of the file.
`alignToSelection`
* Basically unchanged. Will be replaced in the `PlaneGui` class.
This PR introduces the new PlaneBase class.
Most of its functions are rewritten versions of the functions in the original Plane class, with the exception of align_to_point_and_axis_svg.
Note that after this PR the original Plane class does not yet inherit from PlaneBase. This will be done in several following PRs. I will then also explain the reasons behind some of the revised functions in PlaneBase.
The introduction of the PlaneGui class will follow after that.
Issue: #5603.
Small spacing fixes like imports in separate lines
for more clarity, and the position of the license.
Cleaned up the class docstring, so it is in only one place
below the class definition. Also small fixes
in the docstrings of the class methods.
The class is now in upper case `Plane` to conform with Python
guidelines. An alias in lowercase `plane` is still provided
for compatibility purposes; this will be deprecated
in the future.
to save space and have line lengths < 79 characters; added whitespace to comments
and used the self.__repr__() method to shorten the impression to the terminal;
broke the line inside parentheses to make the line shorter; inside alignToSelection() test for faces first
to use alignToFace(), which actually works; leave alignToCurve() for later,
as it doesn't actually do anything at the moment; improved docstrings in isOrtho(),
the orthogonality is tested for u, v, and axis, on the global axis +Y only;
removed wrongly placed comment in restore() method;
improved file docstring at the top.