* Import: Support DXF text rotation - fixes#10882
- Reads and supports text rotation in builtin DXF import
- Makes the builtin DXF import produce Draft texts instead of App::Annotations
- Extends the arguments of Draft make_text()
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Fixes#6187.
Other fixes:
* Made handling of shapes and global placement more consistent.
* Shapes without curves were also triangulated.
* Polygonal faces could have flipped normals and duplicate points.
The commit adds some new functions:
* getThumbnailDir()
Returns the path to the thumbnail directory which is a sub-directory of the Cache directory.
There is no need to always create a unique directory after each restart because it doesn't harm
if the thumbnail directoy contains deprecated files.
* createThumbnailDir()
Creates the thumbnail directoy if it doesn't exist yet.
* getSha1Hash
Helper function to compute a SHA-1 hash of a given path. If the same path is passed
then the hash value will be the same.
This way it can be avoided to create a different image file from a project file
after each restart.
* getUniquePNG
Computes the path of a PNG image file for a given project file. It's also possible
to pass an arbitrary string as argument.
* useCachedPNG
If the PNG image exists and if it's newer than the project file True is returned
and False otherwise.
The changes in detail are:
1. For a given project file it is checked if the thumbnail directory already contains
a cached image. If it's newer than the project file it will used, otherwise it will
be re-created.
2. For the system icon to a given file format it is only checked if the icon already exists.
If yes, it will be used.
Update Python tests to work with other locales
This fixes issues #10917 and #10924
Numeric values were beign compared to strings that did not take into account localizations. The test was modified to work regardless of localization.
There is still a known issue when working with pt_BR.UTF8. The default encoder for this localization is not UTF8 resulting in an error working with a parameter that returned the UTF character for the Greek letter mu in its units.
=================================================================
When in Sketcher edit mode, a tool button is activated, while the view has been changing to view of a different type, it segfaults.
This commit checks the pointer of the view to ensure correct type before activation, and refusing to activate if not of the correct type.
fixes#10809
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.