This commit improves the performance of Python code from FreeCAD macros by:
* using the chrono C++ stdlib header instead of QTime
* checking for the elapsed time ONLY every 1000th Python opcode execution
And this commit fixes time measurement by using a monotonic time source
instead of a normal one.
The previous implementation using QTime would give a negative time duration
if the start time is 23:59:59 and the end time is 00:00:01.
related commit: beeda0e47f051722d6096c99bd949b390e197bdc
In ../src/Mod/Part/App/Geom2d/ sixteen out of seventeen XML
files needed repair as per the GitHub issue. Tabbing in those
sixteen files set to 4-spaces no-tab-chars. Other minor
changes as needed.
* Gui: Improve localization support in VarSet dialog
* Gui: Adopt QObject translate
This is not the ideal implementation but for the 1.0 release this is
currently the better option. A separate issue has been filed for post
1.0 in https://github.com/FreeCAD/FreeCAD/issues/17510 that also covers
the `DlgAddProperty`.
It's basically a port of #10951 to the new start page implementation.
Note: Icon files are not removed but re-used instead.
The commit adds some new functions:
* getThumbnailsImage()
Returns the name of the PNG inside a project file
* getThumbnailsName()
Returns the directory name containing the image files
* getThumnailsParentDir()
Returns the parent directory of the directory containing the image files
* getThumbnailsDir()
Returns the path to the thumbnail 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.
* createThumbnailsDir()
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.
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.
Fix freecadCanOpen() abd DisplayedFilesModel::addFile() to also check for lower-case
file extensions.
* Fix syntax warnings about invalid escape sequences
Backspaces in regular expressions were not escaped properly leading to warnings on every invocation of the program.
* Improve formatting of fcinfo output
* Printing of part BREP file properties (hash and size) has been made optional since these values often change without explicit user action making git diffs almost unreadable by hiding actual changes behind a flood of changed hashes because a base feature further up the history was changed. There is a new option (-p) to re-enable the printing of these file properties.
* Unformatted float outputs have been replaced with proper formatting using f-strings which round the values to a sensible number of places.
* Colors are printed in their native 0-255 range. Printing them as float brings no benefit here.
* Most string concatenation for output has been replaced with f-strings
* Fix printing of color properties
The old CAD model created by the development version of FreeCAD
(in which the Assembly workbench was used) contained joints that,
for some reason, had an empty Joint Connector 1 reference (Reference1).
This was causing an exception and a crash of the Python function
called migrationScript4. The FreeCAD Report view contained:
23:28:29 pyException: Traceback (most recent call last):
File "/FreeCAD/Mod/Assembly/JointObject.py", line 175, in onDocumentRestored
self.createProperties(joint)
File "/FreeCAD/Mod/Assembly/JointObject.py", line 181, in createProperties
self.migrationScript4(joint)
File "/FreeCAD/Mod/Assembly/JointObject.py", line 514, in migrationScript4
if hasattr(joint, "Reference1") and joint.Reference1[0] is not None:
~~~~~~~~~~~~~~~~^^^
<class 'TypeError'>: 'NoneType' object is not subscriptable
This patch attempts to avoid such exceptions by validating the type of
the property variable before accessing it.
Qt handles resize to content on double clicking the separator in the header, by default.
However this does not work in FreeCAD.
There are no comments on why this was done and is therefore treated as bug instead of feature.
Manual testing has been performed after the change and:
* Scaling by double clicking separator in header works
* Sizes are correctly stored in sheet when resizing to content