Commit Graph

367 Commits

Author SHA1 Message Date
Chris Hennes
0517e3dc10 Merge pull request #17564 from kadet1090/new-transform-dialog
Gui: New transform dialog
2025-01-13 11:18:26 -06:00
Yury Shvedov
bc4cddcd04 Macro: allow to specify extra system paths for macro
This introduce new option `-E [ --macro-path]` to specify extra system
paths of macros. The macro found in this paths will appear in `Macros`
dialog at `System macros` tab.

Change-Id: Ic21631ec0ebe8af5c7f42b4fe95400cfb67807d5
2025-01-06 18:14:15 +01:00
Kacper Donat
4702c72fb8 Gui: Rework TaskCSysDragger into new Transform Dialog
This commit refactor ViewProviderDragger and TaskCSysDragger to be more
modern and to support selecting TransformOrigin.
2025-01-04 16:32:52 +01:00
Benjamin Nauck
39402e2083 Revert "Address the poor performance of the existing unique-name generation (#17944)"
This reverts commit 83202d8ad6.

# Conflicts:
#	src/Base/Tools.cpp
#	src/Base/Tools.h
2024-12-16 17:31:43 +01:00
Kevin Martin
5696c9add3 Address the poor performance of the existing unique-name generation (#17944)
* Address the poor performance of the existing unique-name generation

As described in Issue 16849, the existing Tools::getUniqueName method
requires calling code to form a vector of existing names to be avoided.

This leads to poor performance both in the O(n) cost of building such a
vector and also getUniqueName's O(n) algorithm for actually generating
the unique name (where 'n' is the number of pre-existing names).

This has  particularly noticeable cost in documents with large numbers
of DocumentObjects because generating both Names and Labels for each new
object incurs this cost. During an operation such as importing this
results in an O(n^2) time spent generating names.

The other major cost is in the saving of the temporary backup file,
which uses name generation for the "files" embedded in the Zip file.
Documents can easily need several such "files" for each object in the
document.

This update includes the following changes:

Create UniqueNameManager to keep a list of existing names organized in
a manner that eases unique-name generation. This class essentially acts
as a set of names, with the ability to add and remove names and check if
a name is already there, with the added ability to take a prototype name
and generate a unique form for it which is not already in the set.

Eliminate Tools::getUniqueName

Make DocumentObject naming use the new UniqueNameManager class

Make DocumentObject Label naming use the new UniqueNameManager class.
Labels are not always unique; unique labels are generated if the
settings at the time request it (and other conditions). Because of this
the Label management requires additionally keeping a map of counts
for labels which already exist more than once.
These collections are maintained via notifications of value changes on
the Label properties of the objects in the document.

Add Document::containsObject(DocumentObject*) for a definitive
test of an object being in a Document. This is needed because
DocumentObjects can be in a sort of limbo (e.g. when they are in the
Undo/Redo lists) where they have a parent linkage to the Document but
should not participate in Label collision checks.

Rename Document.getStandardObjectName to getStandardObjectLabel
to better represent what it does.

Use new UniqueNameManager for Writer internal filenames within the zip
file.

Eliminate unneeded Reader::FileNames collection. The file names
already exist in the FileList collection elements. The only existing
use for the FileNames collection was to determine if there were any
files at all, and with FileList and FileNames being parallel
vectors, they both had the same length so FileList could be used
for this test..

Use UniqueNameManager for document names and labels. This uses ad hoc
UniqueNameManager objects created on the spot on the assumption that
document creation is relatively rare and there are few documents, so
although the cost is O(n), n itself is small.

Use an ad hoc UniqueNameManager to name new DymanicProperty entries.
This is only done if a property of the proposed name already exists,
since such a check is more-or-less O(log(n)), almost never finds a
collision, and avoids the O(n) building of the UniqueNameManager.
If there is a collision an ad-hoc UniqueNameManager is built
and discarded after use.
The property management classes have a bit of a mess of methods
including several to populate various collection types with all
existing properties. Rather than introducing yet another such
collection-specific method to fill a UniqueNameManager, a
visitProperties method was added which calls a passed function for
each property. The existing code would be simpler if existing
fill-container methods all used this.
Ideally the PropertyContainer class would keep a central directory of
all properties ("static", Dynamic, and exposed by ExtensionContainer and
other derivations) and a permanent UniqueNameManager. However the
Property management is a bit of a mess making such a change a project
unto itself.

The unit tests for Tools:getUniqueName have been changed to test
UniqueNameManager.makeUniqueName instead.
This revealed a small regression insofar as passing a prototype name
like "xyz1234" to the old code would yield "xyz1235" whether or
not "xyz1234" already existed, while the new code will return the next
name above the currently-highest name on the "xyz" model, which could
be "xyz" or "xyz1".

* Correct wrong case on include path

* Implement suggested code changes
Also change the semantics of visitProperties to not have any short-circuit return

* Remove reference through undefined iterator

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix up some comments for DOxygen

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-12-13 10:54:46 -06:00
marioalexis
51c0faff62 Base: Add electromagnetic potential unit 2024-12-13 11:49:44 -05:00
Chris Hennes
ea7e17ba00 Merge pull request #18126 from Ondsel-Development/core_LCS2
Core datums : Card2 : Core implementation
2024-12-06 12:12:04 -05:00
PaddleStroke
4ebb66838c Core: Add App::LocalCoordinateSystem.
Most of App::Origin is moved into this sub class of App::Origin.
Add App::Point. Change graphics of the planes/axis.
Remove scale-by-content behavior and make it fixed size on screen.
2024-11-26 17:36:02 +01:00
Jacob Oursland
0a5c5ee101 App: Reduce BOOST_VERSION workaround to fix boost symbol linker error on Win-Qt5. 2024-11-26 11:13:21 -05:00
PaddleStroke
a558475d8a Rename 'OriginFeature' to 'DatumElement' 2024-11-26 15:36:48 +01:00
PaddleStroke
8f43f3cc8b Core: Rename 'OriginFeature' file to 'Datums' 2024-11-26 15:36:48 +01:00
Benjamin Nauck
518e6b2c51 Add two options to disable addons
Addons can be disabled in two ways:
 * by adding a command line argument `--disable-addon <addon>`
 * and by creating a `ALL_ADDONS_DISABLED` file in the mod root of the addons to disable
2024-11-25 12:16:43 -05:00
wmayer
e7096e457f Core: Generate a static random number in Application::applicationPid()
Using Qt's QCoreApplication::applicationPid() doesn't always give a unique ID so that multiple FreeCAD instances cannot be executed at the same time.
This fixes #17678
2024-11-06 13:52:31 -05:00
Yorik van Havre
c7c23ca158 Merge pull request #17609 from wwmayer/issue_17576
Core: Don't freeze application if lock file already exists
2024-11-04 18:08:51 +01:00
James
d243992499 Safe mode message added as per #17580 (#17640)
* Safe mode message added as per #17580

* Fixed extra whitespace after return

Removed extra whitespace after return spotted by @hyarion

* Incorporated comments by @hyarion
2024-11-04 18:00:28 +01:00
wmayer
de18adba03 Core: Add wrapper function Application::applicationPid() 2024-11-01 15:48:01 +01:00
Benjamin Nauck
f4860bf981 Add "Safe mode" which temporarily disables configs and addons (#16858)
* Add safe-mode which starts freecad in a clean environment

* Integrate safe-mode

* Show "(Safe Mode)" in main window title

* Show safe mode info when safe mode is started

* Created Safe Mode Icon

* Use new icon

* Add PreCompiled.h

* Add exports for windows

---------

Co-authored-by: Gabriel <gaz082@gmail.com>
2024-10-21 18:08:52 +02:00
supermixed
bbb6eeb1ed Core: Import STEP: Cancel button does not cancel (#16499)
* Fix importing .step file when user cancelled import settings dialog
* Refactor object loading python code, fix not using settings when STEP options dialog not shown
* Use custom exception type for user cancelling import instead of `RuntimeError`
* Pull python code out to external file
2024-09-20 08:25:23 -05:00
wmayer
f167e0e8ac Port: Include some important changes of the OpenBSD port
Forum thread: https://forum.freecad.org/viewtopic.php?t=80792
2024-09-09 18:01:38 +02:00
Chris Hennes
a6eadd9f91 Merge pull request #15669 from marioalexis84/fem-link_scope_python_objects
Fem: Fix link scope for Python objects
2024-08-05 10:53:50 -05:00
bgbsww
2cd760ac40 Add a command line option to keep application open after running tests 2024-08-05 10:47:59 -05:00
marioalexis
fd5eb34d6a Base: Add PropertyError exception 2024-08-02 20:19:16 -03:00
wmayer
ba6dc1fa2d Core: Fix Python API name clash: do not expose the App::Part type to Python
Fixes #12539
2024-07-15 10:57:59 -05:00
PaddleStroke
8ed26133ab Core: Add App::PropertyXLinkSubHidden 2024-07-10 10:29:03 +02:00
hlorus
9125631e4f Remove Std_MeasureDistance 2024-06-11 17:57:01 +02:00
bdieterm
cd89e937e9 Core: fix import of FreeCAD in a Python 3.12 interpreter
Importing FreeCAD as a module in a normal Python interpreter (e.g. /usr/bin/python3) stopped working with Python 3.12 (but works normally with Python 3.11). When executing "import FreeCAD as App", the interpreter crashes with "Fatal Python error: PyImport_AppendInittab: PyImport_AppendInittab() may not be called after Py_Initialize()".
The check that causes the error message and abortion was introduced in Python 3.12 via
7f3a4b967c
(and a typo in the error message fixed via)
35dd55005e
2024-06-07 12:19:45 -05:00
wmayer
effbe1e873 App: Prepare for clang-format 2024-06-03 12:52:30 +02:00
Chris Hennes
65f3965717 Merge pull request #14082 from Ondsel-Development/issue_13522_fix_read_lock
Core: Add read lock to fix for possible race conditions reading/writing config files
2024-05-27 10:41:23 -05:00
FEA-eng
14a7ca99cd Base: Add moment unit 2024-05-16 12:51:37 -05:00
wmayer
281230c520 Core: Fix possible race conditions when reading or writing config file 2024-05-06 13:24:17 +02:00
WandererFan
dd09bd2b53 Merge pull request #9750 from hlorus/gsoc2023_measure
GSoC 2023: Unified Measurement Facility
2024-04-29 12:41:54 -04:00
hlorus
e5fee7be14 [App] Add registration functions for unified measurement facility 2024-04-29 09:27:22 -04:00
wmayer
29017e869a App: Add class CleanupProcess to allow to free resources when closing the application 2024-04-25 15:44:22 +02:00
mosfet80
c6f2c8b370 Update Application.cpp
removed commented code
2024-04-20 08:54:02 +02:00
wmayer
112b0158d3 Fixes #11970: Return values of FreeCAD.get*Dir and FreeCAD.get*Path functions have inconsistent path separators 2024-03-22 09:42:31 +01:00
Florian Foinant-Willig
5d539cd940 Add SuppressibleExtension 2024-02-21 16:19:32 +01:00
Pieter Hijma
402421f6aa [Core] Managing Custom Data Elements: VarSet (#12135)
* [Core] Add a basic VarSet document object

* [Core] Add basic tests for VarSets

* Core: Replace the VarSet icon with an outlined one
2024-02-21 10:38:06 +01:00
marioalexis
f9a9ca2e36 App: Add StiffnessDensity property 2024-01-26 13:44:16 -03:00
IMO
42740e9c56 bugfix: exit() is not async-signal-safe! 2023-12-11 18:10:41 +01:00
André Caldas
89dbab9b0e Avoids using getNameInDocument() to test if DocumentObject is attached to a Document.
This patch substitutes by isAttachedToDocument() (almost) everywhere where
getNameInDocument() is used for this purpose.

The very few places not touched by this patch demand a (just a little) less trivial change.
When we change the returning type of getNameInDocument() to std::string,
those places will be easily found, because they shall generate a compiler error
(converting std::string to bool).

Rationale:
The fact that getNameInDocument() return nullptr to indicate
that the object is not attached to a document is responsible for lots of bugs
where the developer does not check for "nullptr".

The idea is to eliminate all those uses of getNameInDocument() and, in the near future,
make getNameInDocument() return always a valid std::string.
2023-12-11 17:37:58 +01:00
Chris Hennes
cfd41683a5 Core: Enable compiling with MSVC /permissive- (#11014)
* Base: Fixes for MSVC permissive-

* App: Fixes for MSVC permissive-

* Gui: Fixes for MSVC permissive-

* Main: Fixes for MSVC permissive-

* Fem: Fixes for MSVC permissive-

* Material: Fixes for MSVC permissive-

* Part: Fixes for MSVC permissive-

* Mesh: Fixes for MSVC permissive-

* Points: Fixes for MSVC permissive-

* Robot: Fixes for MSVC permissive-

* TechDraw: Fixes for MSVC permissive-

* Path: Fixes for MSVC permissive-

* Core; Changes per review comments

* TD: Revision from wandererfan

* [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>
2023-11-27 17:37:29 +01:00
wmayer
1cdff85086 MSVC: fix warnings and build failure 2023-09-23 19:10:32 +02:00
wmayer
1cf1a90a17 App: modernize C++: use default member init 2023-08-23 19:51:44 +02:00
wmayer
af8c05c507 App: modernize C++: return braced init list 2023-08-18 00:36:24 +02:00
wmayer
4991475341 App: modernize C++: use range-based for loop 2023-08-14 16:40:25 +02:00
marioalexis
6acb55b643 App: Initialize StringHasher and StringID classes 2023-08-10 11:55:21 -03:00
wmayer
948cbfccd9 modernize C++: avoid bind
In many cases std::bind() is kept because the code is much simpler
2023-08-08 21:10:16 +02:00
wmayer
702f3b4ddd Core: modernize C++: redundant void arg 2023-08-05 16:50:31 +02:00
Chris Hennes
12f7dff7a6 GUI: Add prominent dev build indicators 2023-08-04 18:21:39 -06:00
bdieterm
d6de5ceb09 fix function name in doxygen annotation 2023-07-10 09:23:59 -05:00