Compare commits

...

591 Commits

Author SHA1 Message Date
PaddleStroke 4cc0a1b718 Assembly: Fix error on open doc in insert tool 2026-01-13 23:48:50 +01:00
Chris Hennes cd6aa97485 Merge pull request #26886 from AjinkyaDahale/sk-fix-symmetric-after-refactor-stage-5
Sketcher: fix `addSymmetric` after refactor stage 5
2026-01-13 15:23:43 -06:00
chris 9f9dc75627 core: qt layout ui: ux/ui: fixes #26048 keep workbench selector visible 2026-01-13 13:51:47 -06:00
PaddleStroke fc82d71c15 Sketcher: Fix symmetry of slot redundancy false positive (#26604)
* Sketcher: Fix symmetry of slot redundancy false positive

Perturb symmetric geometries when using the 'create symmetric constraints' option to avoid numerical singularities in the solver (Jacobian Rank).
If geometry is "perfect", the solver cannot distinguish between the derivative of a Symmetry constraint and an Equal constraint, flagging one as redundant.
2026-01-13 13:48:41 -06:00
Furgo 6812de49a3 BIM: implement baseless walls creation (#24595)
* BIM: Implement smart base removal for Walls

Previously, removing the Base object from an Arch Wall would cause the
wall to reset its position to the document origin and could lead to
unintended geometric changes for complex walls.

This commit introduces a "smart debasing" mechanism integrated into the
Component Task Panel's "Remove" button:

- For walls based on a single straight line, the operation now preserves
  the wall's global position and parametric `Length`, making it an
  independent object.
- For walls with complex bases (multi-segment, curved), a warning dialog
  is now presented to the user, explaining the consequences (shape
  alteration and position reset) before allowing the operation to
  proceed.

This is supported by new API functions `Arch.is_debasable()` and
`Arch.debaseWall()`, which contain the core logic for the feature.

Fixes: https://github.com/FreeCAD/FreeCAD/issues/24453

* BIM: Move wall debasing logic into ArchWall proxy

The logic for handling the removal of a wall's base object was previously
implemented directly within the generic `ComponentTaskPanel` in
`ArchComponent.py`. This created a tight coupling, forcing the generic
component UI to have specific knowledge about the `ArchWall` type.

This commit refactors the implementation to follow a more object-oriented
and polymorphic design:

1.  A new overridable method, `handleComponentRemoval(subobject)`, has been
    added to the base `ArchComponent` proxy class. Its default implementation
    maintains the standard removal behavior.

2.  The `_Wall` proxy class in `ArchWall.py` now overrides this method. All
    wall-specific debasing logic, including the eligibility check and the
    user-facing warning dialog, now resides entirely within this override.

3.  The `ComponentTaskPanel.removeElement` method has been simplified. It is
    now a generic dispatcher that calls `handleComponentRemoval` on the
    proxy of the object being edited, with no specific knowledge of object types.

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

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

* BIM: Add interactive creation of baseless walls

Introduce a new workflow for creating Arch Walls without a dependency on
a baseline object (e.g., a Draft Line).

- The `Arch_Wall` command is enhanced with a "No baseline" mode, controlled
  by a new "Walls baseline" preference, allowing users to create
  placement-driven walls directly in the 3D view.
- The existing `debaseWall` function has been refactored for correctness
  and consistency with the new baseless wall geometry.

Co-authored-by: Yorik van Havre <yorik@uncreated.net>

* BIM: Refactor structure of the Arch Wall command

Refactor the `Arch_Wall` GUI command (`BimWall.py`) for improved
readability, maintainability, and architectural clarity.

- A `WallBaselineMode` Enum is introduced to replace the original
  integer values, making the code self-documenting.
- The monolithic `create_wall` method is broken down into smaller,
  single-responsibility helper functions for each creation mode.
- The `addDefault` method has been removed, with its logic
  integrated into the new structure.

* BIM: Add Draft Stretch support for baseless walls

This commit makes the new baseless Arch Walls graphically editable using
the `Draft_Stretch` tool.

- An API for stretching (`calc_endpoints` and `set_from_endpoints`)
  has been added to the `ArchWall` proxy.
- The `Draft_Stretch` tool is now aware of baseless walls and calls this
  new proxy API to perform the stretch operation, enabling users to
  stretch them.

Co-authored-by: Yorik van Havre <yorik@uncreated.net>

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

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

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

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

* BIM: address CodeQL warnings

* BIM: Fix wall alignment for GUI creation of baseless walls

Fixes an issue whereby creating a baseless wall from the GUI would
ignore the selected `Align` property, always resulting in a
center-aligned wall.

- The underlying geometry generation for baseless walls now correctly
  honors the `Align` property passed by the GUI and API.
- To ensure predictable behavior, the implementation uses the same
  geometric convention as walls built from a base object, making the
  `Align` property work uniformly for all wall types.
- This also corrects the behavior of the `Arch.makeWall` function for
  baseless walls.
- Update unit tests to test wall alignment.

* BIM: Refactor wall geometry generation for improved clarity and maintainability

Improves the internal logic for wall geometry creation, addressing CodeQL warnings and enhancing overall maintainability without changing external behavior.

- The `build_base_from_scratch` method is refactored to unify the separate logic paths for single- and multi-layer walls, reducing code duplication.
- A local helper function is introduced to create face geometry, for better modularity and readability.
- In the `_Wall.execute` method, the control flow that relied on implicit type checking is replaced with an explicit strategy pattern for fusing solids, making the logic more robust.
- Variable names are made more descriptive.
- A NumPy-style docstring is added to better document the function.

* Draft: fix stretching of rotated baseless walls

* BIM: add unit test for stretching baseless walls

* BIM: add regression tests for working-plane-relative coordinates and reuse of base sketches

* BIM: Fix baseless wall creation to respect the working plane

Corrects an issue where baseless walls were created using global
coordinates instead of being relative to the active Draft working plane.

The calculated local placement of the wall is now correctly transformed
into the global coordinate system by multiplying it with the working
plane's placement.

* BIM: Ensure unique baselines for subsequent wall creation

Fixes a bug where creating multiple walls with baselines would
incorrectly reuse the same underlying Sketch or Draft Line object.

The object retrieval logic after the `doCommand` call now correctly uses
`ActiveObject` to get a reliable reference to the new object instead of
relying on a hardcoded name.

* BIM: Make the wall's base object label translatable

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

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

* BIM: use singular for consistency with other labels

Co-authored-by: Roy-043 <70520633+Roy-043@users.noreply.github.com>

* Fix typo

* BIM: address reviewer's comments about improving object reference passing between Python and FreeCAD contexts, and functions

* BIM: remove defensive programming: the callback is only executed as a result of a user's GUI action

* BIM: use the params API to define WallBaseline parameter

* BIM: add Arch Wall tests for joining wall logic

* BIM: add joining logic

* BIM: re-add ArchSketch support

* BIM: re-add multimaterial support on wall creation

* BIM: address CodeQL warning, remove module duplication

* BIM: fix check for SketchArch module when creating sketch-based walls

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Yorik van Havre <yorik@uncreated.net>
Co-authored-by: Roy-043 <70520633+Roy-043@users.noreply.github.com>
2026-01-13 09:30:37 +01:00
tetektoza bb48de8265 Part: Fix Part_Extrude taper angle regression for internal faces (#26781)
* Part: Fix Part_Extrude taper angle regression for internal faces

The taper angle for holes (inner wires) in `Part_Extrude` was not being
negated after the toponaming refactor, causing internal faces to taper
in the wrong direction compared to v0.21.2.

The original makeDraft function correctly handled inner wires by:
- Negating taper for all inner wires in Part_Extrude
- Negating taper only for multi-edge inner wires in PartDesign
This logic was controlled via an isPartDesign function parameter.

When makeElementDraft was introduced for toponaming support, it was
designed to use innerTaperAngleFwd/innerTaperAngleRev fields that were
never ported from realthunder's branch. The cleanup (commit c31ebeeee6)
removed references to these non-existent fields, leaving makeElementDraft
with no inner wire taper handling at all.

So, this fix ports the makeDraft inner wire logic to makeElementDraft by
adding the flag, and counting wires and then triggering proper angle
flip depending on the flag/wire situation.

---------

Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>
2026-01-13 05:52:43 +00:00
PaddleStroke 5792b1173c Gui: Fix broken build in DlgAddProperty.cpp (#26877)
* Gui: Fix broken build in DlgAddProperty.cpp

---------

Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>
2026-01-13 00:01:17 +00:00
PaddleStroke 168cebd41f PartDesign: Extrude: Fix upToShape document not recomputing correctly (#26696)
* PartDesign: Extrude: Fix dir for upToShape

* Update FeatureExtrude.h

* Update FeatureExtrude.h

* Update FeatureExtrude.cpp

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

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

* Update FeatureExtrude.cpp

* Update FeatureExtrude.h

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-01-12 23:07:47 +00:00
Ajinkya Dahale 14280cdbf7 Sketcher: Add new constraints after running addSymmetric
Missed during refactor
2026-01-13 03:32:15 +05:30
Ajinkya Dahale e1a431d5ee Sketcher: Use new constraint element access in add/getSymmetric 2026-01-13 03:32:15 +05:30
dependabot[bot] 08a738a195 Bump github/issue-metrics from 3.25.4 to 3.25.5
Bumps [github/issue-metrics](https://github.com/github/issue-metrics) from 3.25.4 to 3.25.5.
- [Release notes](https://github.com/github/issue-metrics/releases)
- [Commits](https://github.com/github/issue-metrics/compare/55bb0b704982057a101ab7515fb72b2293927c8a...67526e7bd8100b870f10b1c120780a8375777b43)

---
updated-dependencies:
- dependency-name: github/issue-metrics
  dependency-version: 3.25.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-12 21:27:08 +01:00
Billy Huddleston 650ebf693e CAM: Add threshold for treating large-radius arcs as linear in simulator
Arc segments with extremely large radius compared to chord length can
cause floating-point precision issues in simulation. This change
introduces ARC_LINEARIZATION_THRESHOLD to treat such arcs as linear,
improving numerical stability in the simulator.

The following g-code was causing erractic behavior in the simulator due
to large-radius arcs:
```
G2 I88775.835760 J-1936991.545892 K0.000000 X102.063107 Y100.102815 Z12.700001
```

src/Mod/CAM/PathSimulator/AppGL/MillPathSegment.cpp:
- Added ARC_LINEARIZATION_THRESHOLD constant
- Updated arc motion detection to treat large-radius arcs as linear
- Improved handling of arc vs. linear segment classification
2026-01-12 10:52:06 -06:00
Gaël Écorchard 9aa1eb2b0c pixi: Add qt6-wayland dependency on Linux
Signed-off-by: Gaël Écorchard <gael@km-robotics.cz>
2026-01-12 10:50:19 -06:00
Roy-043 2019ff051e Draft: fix constrain error if there is no new point (#26868)
* Add None check before constraining new_point

* [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>
2026-01-12 16:12:13 +01:00
Yash Suthar 2a3dd9cfd6 BIM : Preserve Spreadsheet structure (#26736)
Signed-off-by: Yash Suthar <yashsuthar983@gmail.com>
2026-01-12 16:09:56 +01:00
Kacper Donat 47bd6ac99e PartDesign: Recompute preview only if enabled (#26805)
Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>
2026-01-12 07:20:57 +00:00
Pieter Hijma b173365653 Gui: Add common types to Add Property dialog (#26765)
* Gui: Add common types to Add Property dialog

Add a preselection of commonly used types in the Add Property dialog.
The dialog supports now all properties that have an editor.  This
doesn't necessarily mean that the editor is shown in the Add Property
dialog; some properties should not show their editor in the Add Property
dialog, such as vector and placement.

* Gui: Make Add Property dialog Qt 6 compatible

This change stops using a Qt 6.10 feature and makes it compatible with
all of Qt 6.

* Update src/Gui/Dialogs/DlgAddProperty.cpp

---------

Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>
2026-01-12 07:02:11 +00:00
Rahul Paul a628391406 Test: Add copy button (#25979)
* added a copy button which copies all the errors and traceback to clipboard

* removed unused variable

* removed space at end of Copy string

* copied text notification in status bar

* removed unwanted header

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

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

* Test: Address review comments

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>
2026-01-12 06:35:23 +00:00
Roy-043 95b2a41e78 BIM: fix crazy edge issue with area calculation
Fixes #26777.

The code uses a TechDraw function that considers overly long edges (> ca. 10m) 'crazy'. We need to temporarily change a parameter.
2026-01-11 22:27:11 -06:00
dependabot[bot] 06d490fa4d Bump actions/setup-python from 6.0.0 to 6.1.0
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 6.0.0 to 6.1.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/e797f83bcb11b83ae66e0230d6156d7c80228e7c...83679a892e2d95755f2dac6acb0bfd1e9ac5d548)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-version: 6.1.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-11 22:12:14 -06:00
Kacper Donat 4fae2b83f8 PartDesign: Apply pattern transform in Feature not VP
This is followup for https://github.com/FreeCAD/FreeCAD/pull/26563 which
fixed previews for a given file but broke it for others.

This approach should be more robust as it is applied in the Feature
itself and not on view provider level which should give us more precise
control and per feature transform ability.
2026-01-11 20:45:03 -06:00
Kacper Donat 800990bacd Part: Introduce PreviewUpdateScheduler
This commit introduces PreviewUpdateScheduler class that is responsible
to schedule the true recompute of the preview. View Providers (or other
components) can use this service to ask for the preview recompute to
happend at a time that is convinent for a program and that won't impact
performance.

The provided implementation uses Queued Connections in Qt to calculate
preview essentially on next run of the event loop. It allows business
logic in FreeCAD (like property propagation) to execute fully and then
recompute preview once. This greately reduces number of recompute calls
for previews.
2026-01-11 20:32:50 -06:00
Chris 12d1dba109 Build: cmake: fixes #26247 update cmake to work with new required dep lark for BIM (#26407) 2026-01-11 19:55:38 -06:00
Fabio Rossi 419e1822b8 fix hdf5 detection
avoid side-effects of reusing cached variables (defined PCHDF5_FOUND for
pkgconfig and HDF5_HEAD_FOUND for hdf5.h detections)
2026-01-11 19:50:59 -06:00
freecad-gh-actions-translation-bot 7ddee25ec9 Update translations from Crowdin 2026-01-11 19:42:50 -06:00
timpieces 50c22e10ce Macro: Fix shortcuts in macro editor #26807
- The initial commit to block shortcuts in text edit fields
  (particularly for MacOS, where those shortcuts would activate FreeCAD
  functionality rather than text edit functionality) made a wrong
  assumption.
- It assumed that there were no text edit fields where we would want to
  actually use application shortcuts. In retrospect, this was very
  wrong, and I completely missed the macro editor.
- For now, it should be fine to change the field to only cover
  'LineEdit'. I cannot imagine a case where you'd want to (e.g.) save
  text/document from a LineEdit, but if anyone knows of one then please
  let me know.
- This does mean there are some quirks. For example in the materials
  editor, the description is a TextEdit field. Some text editing
  shortcuts won't work in here now (similar to how they didn't before
  the original commit that I made).
- I've since learned that freecad also has a text editor functionality,
  I've tested that now Cmd+S works for save as it should.
2026-01-11 09:52:06 -06:00
luzpaz bfb911792e CAM: fix typo in Path/Main/Gui/Job.py
Fixes source comment typo
2026-01-11 16:22:05 +01:00
Billy Huddleston f071c5950c CAM: Remove file added by accident.
generate_machine_box.py was added to a PR by mistake.  This PR removes it.
2026-01-11 07:10:23 +01:00
sliptonic b5c289eff0 Merge pull request #26533 from Connor9220/Machine
CAM: Add Machine Library and Editor
2026-01-10 14:33:54 -06:00
Roy-043 bfb72a6925 Add files via upload 2026-01-10 12:30:35 +01:00
Chris Hennes e8af1e42d1 Merge pull request #26811 from kadet1090/ci-fixes
CI: Disalbe ubuntu run temporarily
2026-01-10 00:16:21 -06:00
Billy Huddleston 7094424820 CAM: Refactor Machine Editor UI, replace QToolBox with tabs
Major refactor of the Machine Editor to use QTabWidget for section
navigation. Added tabbed spindle management with add/remove
functionality, split machine configuration into Output Options, G-Code
Blocks, and Processing Options tabs. Updated preferences UI to use tabs
instead of QToolBox.

src/Mod/CAM/Gui/Resources/preferences/PathJob.ui:
- Replace QToolBox with QTabWidget for preferences tabs

src/Mod/CAM/Path/Dressup/Gui/Preferences.py:
- Use QWidget with vertical layout instead of QToolBox for dressup
preferences

src/Mod/CAM/Path/Machine/ui/editor/machine_editor.py:
- Refactor to use QTabWidget for editor sections
- Implement tabbed spindle management with add/remove
- Split configuration into Output Options, G-Code Blocks, and Processing
 Options tabs
- Update post processor selection logic

src/Mod/CAM/Path/Main/Gui/PreferencesJob.py:
- Update to use tabWidget instead of toolBox

src/Mod/CAM/Path/Tool/assets/ui/preferences.py:
- Use QWidget and direct layout instead of QToolBox for asset
preferences
2026-01-09 22:13:16 -05:00
Roy-043 fe86abea92 TechDraw: fix-wrong sWhatsThis for align-commands
sWhatsThis should match the command name.
2026-01-10 00:48:40 +01:00
Kacper Donat ca1c5eb322 CI: Disable ubuntu run temporarily 2026-01-10 00:17:39 +01:00
Kacper Donat 77ee600544 CI: Change github.ref into github.head_ref
This actually allows us to check source branch
2026-01-10 00:13:02 +01:00
Louis Gombert c1b40e3dfc PartDesign: remove preview update on property changed (#26803)
This recompute seemed unnecessary, and caused slowdowns when opening the file and recomputing. This decreases the time necessary to both open and recompute files that use boolean operations, and should not change anything regarding preview computation when the dialog is open.
2026-01-09 23:05:23 +00:00
sliptonic af2d178e57 CAM: Adding retract annotation to drilling commands (#26584)
* Adding retract annotation to drilling commands

checkpoint

* [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>
2026-01-09 19:11:00 +01:00
Roy-043 1eb3742dc7 BIM: Improve ArchStairs Landings code
See https://github.com/FreeCAD/FreeCAD/pull/25278#discussion_r2531791450
2026-01-09 18:46:56 +01:00
sliptonic e9227a6c8a Merge pull request #23980 from davidgilkaufman/adaptive_auto_helix
[CAM] Adaptive automatically pick diameter of helix entrance
2026-01-09 11:46:27 -06:00
sliptonic e45ea4ed13 Merge pull request #25697 from tarman3/profile_numpasses
CAM: Profile - Limit value NumPasses
2026-01-09 11:45:15 -06:00
sliptonic b27eaa5387 Merge pull request #25842 from tarman3/slot_clearance
CAM: Slot - Remove duplication move to clearance height in the end
2026-01-09 11:42:15 -06:00
sliptonic 4b3353bcb9 Merge pull request #26127 from tarman3/tag_tol
CAM: Tag Dressup - Tolerance
2026-01-09 11:36:09 -06:00
sliptonic 1427969fbc Merge pull request #26128 from tarman3/engrave_tol
CAM: EngraveBase - Tolerance
2026-01-09 11:35:51 -06:00
sliptonic 4e008d04e5 Merge pull request #26321 from tarman3/job_setCenterOfRotation
CAM: Job - Fix setCenterOfRotation()
2026-01-09 11:34:49 -06:00
wmayer b180728b9d Assembly: Improve const correctness 2026-01-09 18:09:48 +01:00
wmayer 70d8187964 Assembly: Minor refactor in ViewProviderAssembly::findDragMode
Co-Developed-by: PaddleStroke <pierrelouis.boyer@gmail.com>
2026-01-09 18:09:48 +01:00
sliptonic d2d0e7e3e9 Merge pull request #26658 from Dimitris75/CAM---Experimental-Waterline-Minor-Fixs
CAM - Experimental Waterline Minor Fix
2026-01-09 10:49:41 -06:00
sliptonic 36349357ff Merge pull request #26695 from tarman3/rampentry_zmin
CAM: RampEntryDressup - Fix findMinZ()
2026-01-09 10:45:37 -06:00
sliptonic af1742c0db Merge pull request #26553 from Dimitris75/3D-Surface-Rotational-Scan
CAM: Fix 3D Surface Rotational Scan
2026-01-09 10:43:08 -06:00
petterreinholdtsen dd2ab0e9a1 CAM: Dropped trailing percent from fanuc post processor output. (#26617)
* CAM: Dropped trailing percent from fanuc post processor output.

A trailing percent cause one Fanuc controller to hang when the program
is completed when drip feeding G code, and the minicom ascii upload
was unable to complete the upload.

Had to use emergecy stop to get the machine out of the hang.

* CAM: Adjust Fanuc post processor test to no longer expect trailing percent.
2026-01-09 10:40:02 -06:00
Stanislav a5f66f7240 Draft Workbench: Patch for import DXF without CODE30 (Z for POINT) (#26778)
* Patch for DXF without CODE30 (Z for POINT)

Time to time I use DXF file from measurement microscope without Z for POINT.
This patch help me for download this files without errors.

* [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>
2026-01-09 11:00:36 +01:00
PaddleStroke 5339f415be Assembly: Explode radially: prevent click on item 2026-01-08 20:42:12 -06:00
sliptonic 67d280508b more machine cleanup 2026-01-08 19:26:26 -05:00
pre-commit-ci[bot] ef3bbfdc93 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2026-01-08 19:26:25 -05:00
sliptonic 7eb849f4c6 Revise machine 2026-01-08 19:26:25 -05:00
sliptonic 14c23be550 Code cleanup. 2026-01-08 19:26:25 -05:00
sliptonic 8653c25853 Rearranged some properties.
added back bcnc comment output
2026-01-08 19:26:25 -05:00
Billy Huddleston a2e2f5b518 CAM: Remove colons from labels, fix lint, and update imports
Removed explicit colons from all form labels.
Fixed lint warnings and replaced wildcard imports with explicit
imports for clarity and maintainability.

src/Mod/CAM/Path/Machine/ui/editor/machine_editor.py:
- Removed ':' from all form labels
- Fixed lint warnings (missing docstrings, empty except, etc.)
- Replaced wildcard imports with explicit imports

src/Mod/CAM/Path/Machine/models/__init__.py:
- Updated __all__ and imports for explicit API

src/Mod/CAM/Path/Tool/assets/ui/preferences.py:
- Updated imports to use package-level import

src/Mod/CAM/Path/Machine/models/machine.py:
- Added explanatory comments to empty except blocks
- Fixed duplicate variable assignment
- Added missing class docstrings

src/Mod/CAM/CAMTests/TestMachine.py:
- Fixed unused variable warning by using returned filepath
2026-01-08 19:26:25 -05:00
Billy Huddleston 9a23768983 CAM: Add Machine Library and Editor
This PR introduces a machine object and a machine library, along with a
new machine editor dialog for creating and editing *.fcm machine asset
files. The editor is integrated into the CAM preferences panel, with new
Python modules for the dialog and minimal model validation. Machine
management (add, edit, delete) is now available in the CAM asset
preferences panel.

Key Features:
- Machines now have a type and units property. The machine type can be
used to distinguish between different classes of machines (e.g., mill,
lathe, laser).
- Machine units are stored internally and in the .fcm JSON file as
metric. Note: This differs from how toolbits work (which store units in
their native units)
- Support for 2-5 axis machines.
- Support for multiple spindles (up to 9)
- Processor defaults
- JSON Text Editor with basic validation and line numbers.
2026-01-08 19:26:25 -05:00
Max Wilfinger 5fbd150b18 Part: Fix orientation of internal shells of a solid (#26717)
* Part: Fix orientation of internal shells of a solid

If a solid consists of multiple shells then it can happen that the
internal shells have incorrect orientation that leads to a broken solid.

This fixes issue https://github.com/FreeCAD/FreeCAD/issues/24994

* Part: Add method Feature::fixSolids

This method explicitly checks for solids with the error
'BRepCheck_EnclosedRegion' that means that internal shells of a solid
are wrong.

Using ShapeFix_Solid fixes the solid.

---------

Co-authored-by: wwmayer <wmayer@freecad.org>
2026-01-08 10:35:26 -06:00
Max Wilfinger 3616611ea3 Gui: Handle exception in showValidExpression (#26721)
* Gui: Handle exception in showValidExpression

If an exception is raised inside showValidExpression() because the
expression cannot be evaluated then handle the exception and show it as
invalid expression.

This fixes issue: https://github.com/FreeCAD/FreeCAD/issues/26501
---------

Co-authored-by: wwmayer <wmayer@freecad.org>
2026-01-08 10:34:12 -06:00
Max Wilfinger b0331ed979 PD: Handle reference edge in PolarPattern::getTransformations (#26722)
This fixes issue https://github.com/FreeCAD/FreeCAD/issues/24700

---------

Co-authored-by: wwmayer <wmayer@freecad.org>
2026-01-08 10:31:42 -06:00
Max Wilfinger 78dba6c4a9 Adds an automatic compare link to the weekly release notes. 2026-01-08 10:20:11 -06:00
tetektoza 887c8d3bdf Sketcher: Fix crash when applying constraints during selection batching
Currently, the selection batching optimization introduced in #26663
stores ElementItem/ConstraintItem pointers in a buffer to be processed
on the next event loop cycle via `QTimer::singleShot`.

When a constraint is applied,
`slotElementsChanged()/slotConstraintsChanged()`
rebuilds the list widget, destroying all items. However, the selection
buffer was not cleared, leaving dangling pointers. When
`processSelectionBuffer()`
executed, it attempted to call `QListWidget::row()` on deleted items,
causing a segmentation fault.

So, this patch fixes it by clearing `selectionBuffer` when the list is
rebuilt, since the buffered pointers are invalidated anyway.
2026-01-08 10:17:35 -06:00
PaddleStroke 830329f0fc Add files via upload 2026-01-08 14:46:06 +01:00
tetektoza 0baf444c3e Revert "PartDesign: Bake in geometry transform after boolean"
This reverts commit 527b2de560.

The `bakeInTransform()` call uses `transformGeometry()` which converts
planar faces to BSplineSurfaces. This prevents the refine algorithm
(BRepBuilderAPI_RefineModel) from detecting and merging coplanar faces,
breaking the Refine option for Boolean operations.

This matches Part WB's Boolean behavior which does not use
`bakeInTransform()` and has working refine functionality.
2026-01-08 13:40:52 +01:00
Kacper Donat 8dffa07978 Merge pull request #19132 from tritao/base-remove-boost-signals
Base: Remove Boost-based signals and switch to `FastSignals`.
2026-01-08 12:41:29 +01:00
Saksham Malhotra db8c90b788 Fix sketch redundancy warning (#26064) 2026-01-08 07:53:26 +00:00
PaddleStroke 73a021ca1a Assembly: Ground joint tooltip update (#25852) 2026-01-08 03:52:41 +00:00
tritao 69058376e6 Base: Remove Boost-based signals and switch to FastSignals. 2026-01-07 21:16:16 +00:00
PaddleStroke 11c709d4df Merge pull request #26720 from PaddleStroke/patch-971612
Measure: Fix build failure of new MeasureDiameter
2026-01-07 18:49:39 +00:00
Joao Matos 4ed69332c5 FastSignals: Remove custom C++17 and libc++ build flags. 2026-01-07 15:22:40 +00:00
Joao Matos dc16fe1163 FastSignals: Fix Clang Tidy issues. 2026-01-07 15:22:40 +00:00
Joao Matos d11beca852 FastSignals: Replace ATOMIC_VAR_INIT usages with C++ 20 brace init.
Fixes the following issue:

```
Warning:
/Users/runner/work/FreeCAD/FreeCAD/src/3rdParty/FastSignals/libfastsignals/include/fastsignals/connection.h:76:32:
warning: macro 'ATOMIC_VAR_INIT' has been marked as deprecated
[-Wdeprecated-pragma]
   76 |         std::atomic<bool> m_blocked = ATOMIC_VAR_INIT(false);
      |                                       ^
```
2026-01-07 15:22:40 +00:00
Joao Matos cb69623d1f FastSignals: Fix stress tests. 2026-01-07 15:22:40 +00:00
Joao Matos 9d9b17f972 FastSignals: Build as static library by default. 2026-01-07 15:22:40 +00:00
Joao Matos 95009abb1a FastSignals: Silence warning. 2026-01-07 15:22:40 +00:00
Joao Matos 3e9dbad671 FastSignals: Remove MSVC autolinking. 2026-01-07 15:22:40 +00:00
Joao Matos 4dbc9a8247 FastSignals: Normalize namespace to fastsignals. 2026-01-07 15:22:40 +00:00
Joao Matos 2e8ba02295 FastSignals: Update Catch2 to latest v2 version. 2026-01-07 15:22:40 +00:00
Joao Matos f09bf67217 FastSignals: Add missing <cstdef> include. 2026-01-07 15:22:40 +00:00
Joao Matos 158cf6616e FastSignals: Reorganize include and src folder. 2026-01-07 15:22:40 +00:00
Joao Matos dd24bd47e2 FastSignals: Normalize CMake files. 2026-01-07 15:22:40 +00:00
Joao Matos c045cd68c9 FastSignals: Remove unused build files. 2026-01-07 15:22:40 +00:00
Joao Matos af30d785bd 3rdParty: Add FastSignals library. 2026-01-07 15:22:40 +00:00
wmayer f9cbeb91b1 Simplify code using xerces namespace 2026-01-07 14:37:59 +01:00
Kacper Donat ad0ad85b77 CI: Limit backports to pixi only 2026-01-07 07:11:30 -06:00
jffmichi ae8412468a CAM: fix Radius Mill TipDiameter resetting 2026-01-07 11:53:35 +01:00
Krrish777 123a142292 Improve error message for empty transformed features 2026-01-07 10:20:24 +01:00
xtemp09 58b5820731 Merge pull request #23743 from xtemp09/fem-fix
[FEM] Modernize `QObject::connect` with the new syntax in FEM
2026-01-07 10:18:14 +01:00
aditya dubey a84c748b32 Merge pull request #26057 from TONY8779/fix-fem-existance-typo
Fix typo in FEM module: 'existance' -> 'existence'
2026-01-07 10:17:09 +01:00
Max Wilfinger 3cdc42fd58 Merge pull request #25897 from marioalexis84/fem-magnetic_flux_density 2026-01-07 10:15:20 +01:00
Louis Gombert ec7bbbfdd4 TechDraw: improve draw performance
call 'boundingRect' only after all items have been drawn, using a custom 'addToGroup' function that does not trigger an update.
2026-01-07 09:28:08 +01:00
Krish Sharma 850ad9e0fc Gui: Reorder Add Property dialog fields to Name-Value-Group-Type (#26567)
* Gui: Move Tooltip field after Value field in Add Property dialog

* Gui: Reorder Add Property dialog fields to Group-Type-Name-Value-Tooltip
2026-01-07 09:24:16 +01:00
Leandro Heck d0c7ab7d62 Sketcher: Support Bezier and Offset curves as external geometry (#25144)
* Sketcher: Support Bezier and Offset curves as external geometry

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

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

* Sketcher: Fix adding projection of external arc of circle

In processEdge() it's checked if first and last point of the projected arc of circle are almost equal. If yes then a full circle
is assumed but this conclusion is not necessarily correct because it's still possible that the external arc of circle is very
short. The better criterion is to check the parameter range of the arc of circle.

See also: https://github.com/FreeCAD/FreeCAD/pull/25144#issuecomment-3502916685

---------

Co-authored-by: wwmayer <wmayer@freecad.org>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-01-07 09:23:28 +01:00
Max Wilfinger e9a66713ef Merge pull request #22951 from AjinkyaDahale/sk-refactor-stage-5
[Sketcher] Stage 5 of refactors
2026-01-07 09:23:10 +01:00
mac-the-bike f548697603 FEM: Addition of "half cycle" animation (#24129)
* Animation of Results - addition of half cycle

* Delete src/Mod/Fem/Gui/Resources/ui/ResultShow.ui

* Delete src/Mod/Fem/femtaskpanels/task_result_mechanical.py

* Delete src/Mod/Fem/femviewprovider/view_result_mechanical.py

* Add files via upload

* Add files via upload

* Add files via upload

* Update view_result_mechanical.py

* Update task_result_mechanical.py

* Update task_result_mechanical.py

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

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

* Delete user_guide_animate.txt

* Delete results.png

---------

Co-authored-by: mac-the-bike <mac-the-bike@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-01-07 09:22:07 +01:00
PaddleStroke 8bfbeac40f PartDesign: Enable drag and drop of shapeBinders (#25264)
* PartDesign: Enable drag and drop of shapeBinders

* [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>
2026-01-07 09:21:58 +01:00
Kavin Teenakul 5e482a8310 [Std_Measure] Add diameter measurement (#24853)
* Add diameter measurement support

* change author name and change icon

* correct svg size to 64x64

* Update src/Mod/Measure/App/MeasureDiameter.cpp

Co-authored-by: Kacper Donat <kadet1090@gmail.com>

* somehow to icon color is undefine in inkscape, change to black

* Revert "somehow to icon color is undefine in inkscape, change to black"

This reverts commit 2277c1b9f4a7ab7519856986e2d6aec6e37ebf3e.

	modified:   src/Mod/Measure/Gui/Resources/icons/Measurement-Diameter.svg

* fix black color icon

---------

Co-authored-by: Kacper Donat <kadet1090@gmail.com>
2026-01-07 09:16:24 +01:00
Kacper Donat 77a43c55ef Merge pull request #26703 from tetektoza/fix/25840_draw_parts_of_constraints_ontop_of_others
Gui: Render constraint text, arrowheads and constraint icons above geometry lines
2026-01-07 05:39:05 +01:00
tetektoza b1fdf659d8 Sketcher: Disable depth testing for constraint icons
Add `SoDepthBuffer` nodes around the constraint group to disable depth
testing for constraint icons. This ensures icons render on top of
geometry lines regardless of Z position, improving visibility and
selectability.
2026-01-06 20:08:35 +01:00
tetektoza 4aa4f2663e Gui: Render constraint text and arrowheads above geometry lines
Add Z offset for arrowheads and explicitly enable depth testing for
constraint lines in SoDatumLabel. This ensures constraint lines render
below geometry (respecting zConstr level) while text and arrowheads
render on top for better visibility and selection.
2026-01-06 20:07:25 +01:00
drwho495 9b64da827a TopoNaming: Improve ElementMapVersion definition. (#26691)
This change makes the program only mark an object's ElementMapVersion with the "1" prefix if the object has a hasher AND an element map.
2026-01-06 15:36:19 +00:00
tarman3 2d33855432 CAM: RampEntryDressup - Fix findMinZ() 2026-01-06 10:11:40 +02:00
pre-commit-ci[bot] c19eb5c0e0 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2026-01-06 01:40:39 +00:00
Ajinkya Dahale 9791d3f6d5 Sketcher: Override clang-format for some readability
See https://github.com/FreeCAD/FreeCAD/pull/22951#discussion_r2314544159.
2026-01-06 07:08:17 +05:30
Ajinkya Dahale 9000dc3c70 Sketcher: Add test stubs for SketchObject::addCopy() 2026-01-06 05:59:10 +05:30
Ajinkya Dahale e9469d93cc [Sketcher] Use replaceGeometries() in join() 2026-01-06 05:59:10 +05:30
Ajinkya Dahale 50a091c0ca [Sketcher] Use auto where possible 2026-01-06 05:59:10 +05:30
Ajinkya Dahale c02969da9c [Sketcher] Refactor SketchObject::updateGeometryRefs() 2026-01-06 05:59:10 +05:30
Ajinkya Dahale 9993cc123c [Sketcher] Refactor SketchObject::onChanged()
Break into pieces depending on which property has been passed.
2026-01-06 05:59:10 +05:30
Ajinkya Dahale e34d6604d7 [Sketcher] Refactor removeAxesAlignment()
Use switch case for more readability, and move some if and for indentations
2026-01-06 05:59:10 +05:30
Ajinkya Dahale abc3c74abd [Sketcher] Refactor SketchObject::validateExpression() 2026-01-06 05:59:10 +05:30
Ajinkya Dahale 585ce5ec03 [Sketcher] Refactor SketchObject::migrateSketch()
Manipulate some if-else statements, for loops, and possibly replace them with
std algorithms.
2026-01-06 05:59:10 +05:30
Ajinkya Dahale 169a10c7d2 [Sketcher] Refactor some if-else statements in SketchObject 2026-01-06 05:59:10 +05:30
Ajinkya Dahale 0c2f4df8d5 [Sketcher] Refactor addSymmetric and getSymmetric
Rearrange some if-else and use `std::find_if` instead of looping.

[Sketcher][WIP] Refactor `getSymmetric` and `addSymmetric`
2026-01-06 05:59:10 +05:30
Ajinkya Dahale 78cdd8d59d [Sketcher] Refactor delExternalPrivate() 2026-01-06 05:59:10 +05:30
Ajinkya Dahale bf51899580 Sketcher: [test] Add test for addExternal and delExternal 2026-01-06 05:59:10 +05:30
Ajinkya Dahale 0ea4c7c280 [Sketcher] Move some checks to Constraint 2026-01-06 05:59:10 +05:30
Ajinkya Dahale 38a0443195 [Sketcher] Use range-for loop where straightforward 2026-01-06 05:59:04 +05:30
Ajinkya Dahale db5ffb4769 [Sketcher] Refactor SketchObject::addCopy()
if and for rearrangement for readability.
2026-01-06 05:42:44 +05:30
Ajinkya Dahale 43a257a1cb [Sketcher] Refactor SketchObject some more 2026-01-06 05:42:44 +05:30
Ajinkya Dahale 8e46e74ee5 [Sketcher] Refactor based on loops and extraction into functions
May contain some untested changes
2026-01-06 05:42:44 +05:30
Ajinkya Dahale a16be08159 [Sketcher] Refactor some loops for understandability
Changes include:
1. Modernize `for` loops with range whenever possible.
2. Flip `if` statements for a "flatter" flow.
3. Use internal functions for repeated identical tasks.
2026-01-06 05:42:44 +05:30
Ajinkya Dahale ca97889e47 [Sketcher] Refactor SketchObject:validateExternalLinks() 2026-01-06 05:42:44 +05:30
Ajinkya Dahale 9c87e26280 [Sketcher][test] Add tests for replaceGeometries() 2026-01-06 05:42:44 +05:30
Ajinkya Dahale 404482f48e [Sketcher] Fix issue in replaceGeometries when more old than new 2026-01-06 05:42:44 +05:30
Adrian Insaurralde Avalos ede7013f55 set BUILD_DYNAMIC_LINK_PYTHON=OFF for mac and linux release builds
fix regresion #25098
2026-01-05 15:59:05 -06:00
WandererFan cc707c98eb TechDraw: Axo Dimension Fixes (#26445)
* [TD]fix dim text on wrong side of dim line

- this fixes the problem when the dimension line is +/- vertical

* [TD]Avoid use of CosmeticVertex for Axo Dimension

* [TD]fix CI warnings re unused variable

* Update DrawViewPyImp.cpp per review comments.
2026-01-05 19:31:17 +00:00
Chris Hennes a985f63e25 Merge pull request #26554 from PaddleStroke/patch-106258
Sketcher: Reverse #25478 and #26033 and fix #13852
2026-01-05 08:50:47 -09:00
PaddleStroke 0fa707c523 Sketcher: Speed up large bulk Selection in edit (#26663)
* Sketcher: Speed up large bulk Selection in edit

* Update ViewProviderSketch.cpp

* Update src/Mod/Sketcher/Gui/TaskSketcherConstraints.cpp

---------

Co-authored-by: Kacper Donat <kadet1090@gmail.com>
2026-01-05 17:41:45 +00:00
wandererfan f64408de2e [TD]prevent frames on exported/printed page 2026-01-05 17:28:04 +00:00
wandererfan fa8e81f0d6 [TD]restore view frame toggle in context menu
#This is the commit message #2:
2026-01-05 17:28:04 +00:00
wandererfan c95ce2c06d [TD]remove obsolete preference 2026-01-05 17:28:04 +00:00
Ryan Kembrey bfd3fc7268 TechDraw: Implemented View Frame Mode preference 2026-01-05 17:28:04 +00:00
PaddleStroke 21f0d44320 Sketcher: Fix selection & zoom lag in large sketches (#26671)
* Sketcher: Fix selection & zoom lag in large sketches

* Update src/Mod/Sketcher/Gui/EditModeConstraintCoinManager.cpp

Co-authored-by: Kacper Donat <kadet1090@gmail.com>

---------

Co-authored-by: Kacper Donat <kadet1090@gmail.com>
2026-01-05 17:22:10 +00:00
sliptonic 962db90dc7 Merge pull request #26647 from Connor9220/FixToolbitLabelAndControllerNaming
CAM: Fix duplicate label issues with toolbits
2026-01-05 11:15:02 -06:00
Roy-043 530aba61db BIM: remove v1.1 Sill Height code (#26641) 2026-01-05 18:09:49 +01:00
Yash Suthar 9e22524e11 Core: Fix premature merge of property in debug mode
Signed-off-by: Yash Suthar <yashsuthar983@gmail.com>
2026-01-05 17:51:47 +01:00
wandererfan dc0901839e [TD]prevent crash on cosmetic element delete 2026-01-05 07:43:55 -09:00
Kacper Donat 2682d68809 Sketcher: Use correct namespace for tr functions in DSH
The `lupdate` tool from Qt used to extract translations from files was
not in sync with what the macros defined in the code. The mismatch came
from two places:

1. The DrawSketchHandeler used non fully-qualified name for the
   context whereas lupdate assumed the FQN.
2. Deriving DrawSketchHandlers did not override the translate method
   context to their own class names while lupdate assumed that they do.

While it's not fully clear if what `lupdate` does here is correct
(it's a lot of assumptions) it's way easier to fix our metadata than
fight with lupdate.
2026-01-05 07:42:59 -09:00
WandererFan 7abdbe0ce0 Surface: Provide geometry to Measure module (#26479)
* [Surf]provide geometry to Measure

* [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>
2026-01-05 17:39:06 +01:00
PaddleStroke dfbdb2005c Update CommandCreateJoint.py 2026-01-05 16:25:50 +01:00
PaddleStroke ae075c1a73 Assembly: RackPinion tooltip fix 2026-01-05 16:25:50 +01:00
PaddleStroke 450789e77b Sketcher: Fix text sometimes reversed when switching from one sketch edit to another.
Sometimes when user would switch from editing one sketch to edit to another sketch by double clicking on the new sketch, without living the previous sketch, it would then render the text of constraints backward. This was happening because the unsetEdit of the previous sketch was clearing the selection and adding the old sketch as selected. Then the new setEdit was failing to find the correct editing placement resulting in backward text.
2026-01-05 16:17:04 +01:00
PaddleStroke 26723cf209 Sketcher: Reverse #25478 and #26033 2026-01-05 16:17:04 +01:00
luzpaz 9fde6cbac0 BIM: Fix tooltip string in dialogLibrary.ui
Removes ellipsis from tooltip.  
Not eligible for backport.

Fixes https://github.com/FreeCAD/FreeCAD-translations/issues/344
2026-01-05 13:25:13 +01:00
Captain 2b97d553f9 PD: fix gizmo direction when the calculated point lies outside the face (#26616)
* PD: fix gizmo direction when the calculated point lies outside the face

* [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>
2026-01-05 12:44:01 +01:00
marioalexis 92529da3fc Fem: Add support for 2D geometries to SectionPrint 2026-01-05 08:57:07 +01:00
freecad-gh-actions-translation-bot 2592406b35 Update translations from Crowdin 2026-01-05 08:47:20 +01:00
luzpaz 1559e8a9cf BIM: Fix typo in ArchComponent.py documentation
Removes ellipsis to avoid confusion for translators.

Fixes https://github.com/FreeCAD/FreeCAD-translations/issues/341
2026-01-05 07:10:10 +01:00
luzpaz 0cf92f28c7 CAM: Fix typo in tooltip for ToolBitLibraryEdit.ui
Modifies 'tool bit' to 'toolbit'.

Fixes https://github.com/FreeCAD/FreeCAD-translations/issues/339
2026-01-05 07:08:39 +01:00
luzpaz cd221ba09d BIM: Update tooltips for row-related actions
Modifies tooltips that mention 'line(s)' and swaps them for the correct nomenclature, 'row(s)' 

Fixes https://github.com/FreeCAD/FreeCAD-translations/issues/343

cc @chennes
2026-01-05 07:08:19 +01:00
pre-commit-ci[bot] 60f76ede3e [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2026-01-05 00:46:36 +00:00
Dimitris75 af55805030 CAM - Experimental Waterline Minor Fix
- Offset and None cut Pattern error
-  Ensure the tool is directly above the entry point before plunging,
- Retract to SafeHeight instead of ClearanceHeight between transitions
2026-01-05 02:26:56 +02:00
PaddleStroke c8106982de Sketcher: Use DenseQR for small sketches to avoid SparseQR rank issues (#26559) 2026-01-04 14:57:13 -06:00
Chris Hennes 212350acb8 Merge pull request #26577 from Roy-043/Draft-fix-regression-in-Pattern-display
Draft: fix regression in Pattern display
2026-01-04 10:44:41 -09:00
Billy Huddleston a7c9cbee9e CAM: Add 0.05 um to V-bit tip diameter to prevent invalid sketch constraints
This commit applies a simple fix to the V-bit tool definition, adding a
small offset (+0.05 um) to the tip diameter. This prevents the sketch
from generating invalid constraints due to a zero or near-zero tip size.

src/Mod/CAM/Path/Op/SurfaceSupport.py:
- Add +0.05 um to tip diameter calculation to avoid constraint errors in
sketches
2026-01-04 10:42:06 -09:00
Chris Hennes 239567c03c Merge pull request #25009 from tetektoza/fix/24290_respect_selectable_option_if_nested_objs
Gui: Respect Selectable property for objects inside Part containers
2026-01-04 10:37:04 -09:00
Kacper Donat c938645843 Gui: Migrate to new styles
Since some time we have new stylesheets based on style parameters. For
compatibility reasons however old stylesheets were left in the project -
this commit removes them by reapplying the theme if old stylesheet is
detected.
2026-01-04 10:33:40 -09:00
Kacper Donat f819011d81 PartDesign: Fix misplaced preview for patterns
Previous solution did not take into account supporting shape transform
which should now be handled correctly.
2026-01-04 10:31:46 -09:00
Billy Huddleston 2a24a539e6 CAM: Fix duplicate label issues with toolbits
Addresses problems caused by the "Allow duplicate object labels in one
document" option. Toolbit sub-objects now always get unique labels by
temporarily disabling this option during copy, preventing expression and
property binding errors. Also ensures tool controllers always use the
"TC: " prefix for consistency.

src/Mod/CAM/Path/Tool/shape/models/base.py:
- Temporarily disable DuplicateLabels during shape copy to enforce
unique labels

src/Mod/CAM/Path/Main/Gui/Job.py:
- Add "TC: " prefix to tool controller names when adding from the Job
panel
2026-01-04 13:39:20 -05:00
tetektoza 3f49f3f059 Gui: Add hidden anchor object to root for transparency (#26590)
* Gui: Add hidden anchor object to the root for transparency

Image planes with transparency failed to render correctly in empty scenes
because OpenInventor's two-pass transparency rendering requires at least
one opaque object to properly initialize the depth buffer.

The fix adds a zero-scaled cube with no material node (making it use
OpenGL's default opaque material) to each image plane's scene graph.
This hidden object:
- Acts as a depth buffer anchor for transparent rendering
- Is invisible (scaled to 0,0,0)
- Has negligible performance impact

This matches the workaround already used in the rotation center indicator
and resolves the issue where image transparency only worked when the
rotation center, grid, or other opaque objects were visible.

* Gui: Exclude hidden anchor from bounding box calculations

Prevents the hidden anchor from affecting "fit all" and other bounding box
operations by wrapping it in `SoSkipBoundingGroup`.
2026-01-03 04:06:26 +00:00
Krrish777 d944df04e1 Fix: Update PartDesign Boolean dropdown immediately before recomputation 2026-01-03 02:41:28 +01:00
PaddleStroke 07756cc838 Part: Toposhape: fix regressions due to changes in getElementTypeAndIndex (#26596)
* Part: Toposhape: fix regressions due to changes in getElementTypeAndIndex

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

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

* Update TopoShape.cpp

* Update TopoShape.cpp

* Update TopoShape.cpp

* Update TopoShape.h

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-01-02 19:37:09 +01:00
chris 6df651b5c8 partdesign: fix issue #25811 while not breaking #14720 topo naming 2026-01-02 18:52:30 +01:00
PaddleStroke 9f2b0f910b Sketcher: Fix snap to axis not working (#26558)
When snapping to an axis, snapToObject returns false because we should also be able to snap to grid at the same time. Recent changes made the end return to be the initial unmodified position. Breaking snap to axis
2026-01-02 18:10:50 +01:00
Kacper Donat 1dc611fcc1 Gui: Prevent whole-object highlight when picked list is enabled (#26589)
* Gui: Prevent whole-object highlight when picked list is enabled

Removed the logic that forced `onTop=1` when `needPickedList()` is true
in View3DInventorSelection. This was causing the entire object to be
highlighted instead of just the selected sub-element when the "Picked
object list" option was enabled.

* Part: Remove `needPickedList` mat override to prevent rendering artifact

The `needPickedList` check in `SoBrepFaceSet` was triggering
unnecessary material override processing that caused face clipping
artifacts when the "Picked object list" option was enabled in Selection
View. This check has been removed as the picked list functionality works
independently of the rendering path.
2026-01-02 18:09:04 +01:00
PaddleStroke be6be63764 Sketcher: Fix large sketch being laggy (#26598)
* Sketcher: Remove old constraint positioning logic that was making sketcher laggy

* [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>
2026-01-02 16:36:49 +01:00
Roy-043 8e47327323 Part: update some GUI texts (title case mod) (#26591) 2026-01-02 08:25:37 +01:00
tetektoza c66aa58a60 Part: Remove needPickedList mat override to prevent rendering artifact
The `needPickedList` check in `SoBrepFaceSet` was triggering
unnecessary material override processing that caused face clipping
artifacts when the "Picked object list" option was enabled in Selection
View. This check has been removed as the picked list functionality works
independently of the rendering path.
2026-01-01 21:21:03 +01:00
tetektoza 4dcef14bd8 Gui: Prevent whole-object highlight when picked list is enabled
Removed the logic that forced `onTop=1` when `needPickedList()` is true
in View3DInventorSelection. This was causing the entire object to be
highlighted instead of just the selected sub-element when the "Picked
object list" option was enabled.
2026-01-01 21:20:55 +01:00
Roy-043 34441b8101 Draft: fix regression in Pattern display (Refactor texture handling in view_base.py) 2026-01-01 14:04:27 +01:00
Roy-043 21e7fa1e8b Draft: fix regression in Pattern display (add find_coin_node_by_name function)
Adapted existing code attribution and added a new function to find a node by name.
2026-01-01 14:01:34 +01:00
pre-commit-ci[bot] 61e053ffb9 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2025-12-31 02:40:09 +00:00
Dimitris75 5883bad32b Fix 3D Surface Rotational Scan
Retract to Clearance Height Before Transition Between Passes
2025-12-31 04:29:42 +02:00
Kacper Donat f5759e580b Merge pull request #26495 from tetektoza/fix/26441_fix_exported_html_file_is_not_valid
Gui: Fix XHTML and X3D export validation and rendering issues
2025-12-30 18:40:39 +01:00
tetektoza df25bd3cdb Part: Preserve child visibility when deleting compound copies (#26509)
* Part: Preserve child visibility when deleting compound copies

Currently, if we have a FC document two compounds, when one of them is a
copy of the other containing same children and we delete the copy
compound to keep the children, their visibility state changes.

The cause of that was a part of code in `onDelete()` method, which was
unconditionally calling `showViewProvider()` on every child object,
without checking if other compounds still claim those children or what
the current visibility should be.

So this patch adds parent-checking logic before changing visibility. The
visibility is only updated if the child is truly orphaned. So in the
scenario where we have the children referenced STILL by some compounds,
the visibility remains unchanged. It only changes when child has truly
no parents.

* Part: Use std::ranges::find for finding parent
2025-12-30 17:22:37 +00:00
tetektoza 80532b78e1 Gui: Add Selectable property to Part containers
Change `ViewProviderPart` to inherit from `ViewProviderGeometryObject`,
giving Part containers the Selectable property. This allows recursive
selectability checks to respect the entire container hierarchy.
2025-12-30 18:12:13 +01:00
tetektoza 57dd04f214 Gui: Use encodeAttribute when escaping XML attributes for XHTML 2025-12-30 17:22:00 +01:00
drwho495 e9ea3d0d25 TopoNaming: Enable migration code for 1.0.X -> 1.1 (#26538) 2025-12-30 13:24:09 +01:00
Roy-043 0ced25c6dc BIM: fix component VerticalArea calculation (#26254) 2025-12-30 09:02:30 +01:00
theo-vt cc60502708 Sketcher.scale: Scale label of modified constraints (#26442)
* Sketcher.scale: Scale label of modified constraints

* Sketcher.scale: Narrowing conversion on constraint index
2025-12-29 21:38:12 +01:00
Adrian Insaurralde Avalos 3dce4c831d FEM: sanitize NAN format on frd import
depending on c runtime lib and possibly locale calculix may format NAN differently so we need to sanitize when importing the results
2025-12-29 18:19:57 +01:00
Chris Hennes bb8d4a8095 CI: Update backport Action to use new secret token
When using the default GitHub token, no further Actions are triggered, which means a backport PR is not checked against the normal CI runs, and it should be. This switches to using a token generated by the freecad-ci-runner GitHub account.
2025-12-29 17:59:05 +01:00
Christoph Moench-Tegeder 57b970f795 add pybind11 include path in MeshPart CMakeLists
This could be a return of parts of commit d4feb51402
Without these, the rc1 build fails on FreeBSD with "pybind11/eigen.h not
found" - the layout of the pybind11 directories on the BSDs may differ
somewhat from your typical Linux distribution. But then, on Linux, this
additional include path will just point to an already-known location.
2025-12-29 17:56:31 +01:00
Chris Hennes e858a13a5f Gui: Add explicit find_package for Qt6::GuiPrivate 2025-12-29 17:51:47 +01:00
Roy-043 2292316f22 BIM: prevent crash when switching BIM_View Render Mode
Fixes #24929.

Disabled animations in viewer to prevent crashes.
2025-12-29 17:45:04 +01:00
Chris Hennes 8b9048a784 PD: Add case for when scripts set Midplane=False 2025-12-29 17:42:13 +01:00
Alfredo Monclus 24b9cdb4f9 PartDesign: fix transform removal causing an invalid base feature on the next solid if it was broken itself 2025-12-29 17:41:36 +01:00
Yash Suthar ee7d84bb03 Fix : added empty link check to prevent null entry in document link map (#26406)
Signed-off-by: Yash Suthar <yashsuthar983@gmail.com>
2025-12-29 17:35:01 +01:00
Rahul Paul 1002bcb398 [MOD] Fix premature evaluation and recursive updates in Image Plane Settings (#26390)
* Fixed image editor

* decoupled the chnage height and width fns

* final fixes
2025-12-29 17:34:29 +01:00
PaddleStroke 20e45231c5 PartDesign: Fix upToFace not working with non-ASCII filenames (#26514)
* PartDesign: Fix upToFace not working with non-ASCII filenames

* Update TaskExtrudeParameters.cpp
2025-12-29 17:33:19 +01:00
freecad-gh-actions-translation-bot 7fe10f7436 Update translations from Crowdin 2025-12-29 11:31:39 +01:00
Roy-043 776b2f2d5a BIM: fix transparency of curtain walls in BIMExample.FCStd
Curtain walls in the BIM example file did not have transparent glass panels.
2025-12-28 07:53:28 +01:00
tetektoza 38bb34ab85 Gui: Clean up XHTML meta tags per Nu validator feedback
- Change http-equiv="Content-Type" to simpler charset="utf-8"
- Remove unnecessary type="text/javascript" from script tag
2025-12-27 19:38:34 +01:00
tetektoza 2ae054e470 Gui: DOCTYPE and structure improvements
Fix X3D standalone export (.x3d):
- Use proper X3D 3.3 DOCTYPE instead of XHTML DOCTYPE
- Remove problematic default namespace declaration
- Use xsd:noNamespaceSchemaLocation for better parser compatibility
- Remove invalid width/height attributes

Fix XHTML/X3DOM export (.xhtml):
- Wrap navigation buttons in <div> (required by XHTML Strict)
- Keep X3D elements unprefixed for X3DOM compatibility
- Add proper XHTML structure with XML declaration
2025-12-27 19:22:28 +01:00
tarman3 39eec0cfff CAM: Slot - Remove duplication move to clearance height in the end 2025-12-27 20:05:10 +02:00
tetektoza fe7bceeb79 Gui: Escape XML special characters in attributes for XHTML
Add escapeXmlAttribute() helper function to properly escape special
characters in XML attribute values:
- Double quotes (") --> &quot;
- Ampersands (&) --> &amp;
- Less-than (<) --> &lt;
- Greater-than (>) --> &gt;
- Single quotes (') --> &apos;
2025-12-27 18:51:52 +01:00
tetektoza 679d4c2397 Gui: Fix XHTML doc structure
- Add missing <title> element in <head> (required by XHTML Strict)
- Add <body> wrapper around content (required by XHTML)
- Add Content-Type meta tag for proper character encoding
- Fix indentation of buttons to be inside body element
2025-12-27 18:48:22 +01:00
sliptonic c5ce65cfb8 Merge pull request #25398 from tarman3/migrateRampDressups
CAM: _migrateRampDressups - fix #25391
2025-12-27 11:31:07 -06:00
Chris Hennes 51d2c88b02 PD: For Body get the color from the tip
Mostly affects STEP export.
2025-12-27 18:29:41 +01:00
Chris Hennes 7da646754a Import: Revert recent STEP file object naming work
After discussion in several recent PR review meetings the Maintainer
team has decided to roll back some recent work on object naming in STEP
files. Inadequate automated testing has led to a situation where every
change made to address one bug introduces another someplace else. It
is difficult to determine which, if any, of these fixes represent an
appropriate path forward, versus fixing a symptom rather than the
underlying problem.

---

Revert "[pre-commit.ci] auto fixes from pre-commit.com hooks"
This reverts commit 59715114f5.

Revert "core: fix various issues exporting step files, ie. #25540 #24962 #25567"
This reverts commit e226e9b06e.

Revert "export: step file preserve last feature when exporting step file, fix issue #25567"
This reverts commit 9c48c9a3e3.

Revert "core: preserve body name in step file when exporting part that contains body with feature, fixes #24962"
This reverts commit 246218b28b.

Revert "Import: STEP export preserve body names (#25042)"
This reverts commit f218c5f25c.

Revert "Import: Export tip when body is selected (#24678)"
This reverts commit 6fd6558040.
2025-12-27 18:29:41 +01:00
Chris Hennes a4bff812d7 PD: Modify tests to use SideType instead of Midplane 2025-12-27 18:28:01 +01:00
sliptonic 92d2e669f2 Merge pull request #26324 from tarman3/array_refactor_PathArray
CAM: Array - Refactor class PathArray
2025-12-27 11:26:48 -06:00
sliptonic 96bec2fd4d Merge pull request #26322 from tarman3/utils_splitArcs_deflection
CAM: Path.Post.Utils.splitArcs() - Fix zero deflection
2025-12-27 11:22:48 -06:00
sliptonic 83f74f32c2 Merge pull request #26422 from Dimitris75/CAM-Fix-Waterline-OCL-Adaptive
CAM: Waterline OCL Adaptive - Fix Linear and Angular Deflection Values
2025-12-27 11:22:21 -06:00
sliptonic ebeb7b50c3 Merge pull request #25841 from tarman3/slot_clearPath
CAM: Slot - Clear path if can not create slot
2025-12-27 11:21:40 -06:00
sliptonic 798ba4d9aa Merge pull request #25374 from tarman3/engrave_baseobject
CAM: Engrave - Remove useless property BaseObject
2025-12-27 11:21:23 -06:00
sliptonic 2d00530225 Merge pull request #22484 from tarman3/ramp
CAM: RampEntry Dressup - Remove X0Y0 from beginning
2025-12-27 11:20:06 -06:00
horseDeveloper 4892154faf Fixing Leftover references from migration from freecadweb.org (#26163) 2025-12-26 11:11:12 -06:00
tetektoza b44d75454f Gui: Respect parent container selectability in nested selections 2025-12-26 13:55:02 +01:00
tetektoza 17543ea69e Gui: Respect Selectable property for objects inside Part containers
Currently if user selects object with `Selectable=false` property which
is nested inside a Part container, for example `Part->Body->Pad`, parent
Part container will get highlighted in the 3D view, even though the user
clicked on a non-selectable child object.

Cause of that is that tree view's `getTopParent()` function resolves
nested objects selections to their top-level container. When a Pad
inside Part is selected, `SoFCUnifiedSelection` was only checking Part's
`isSelectable()` status, even though the target is `Pad`.

So the fix is to resolve subname to get the final target object and
checks its `isSelectable()` status before checking for highlighting.
2025-12-26 12:46:07 +01:00
ᴩʜᴏɴᴇᴅʀᴏɪᴅ f253f453d6 [ Show ]: Update SPDX License Identifiers 2025-12-25 12:07:49 -06:00
Chris Hennes 2fbc36d472 Tools: Add Surface to translations 2025-12-25 19:06:55 +01:00
PhoneDroid a7012e7bc4 [ Sandbox ]: Update SPDX License Identifiers 2025-12-25 12:02:25 -06:00
PhoneDroid 4d0348dd0f [ Robot ]: Update SPDX License Identifiers 2025-12-25 12:01:29 -06:00
ᴩʜᴏɴᴇᴅʀᴏɪᴅ 670da3d796 SPDX [ 41 ][ Src / Mod / Sketcher ] (#25135) 2025-12-25 12:00:22 -06:00
PhoneDroid 8abd25c999 [ App ]: Update SPDX License Identifiers 2025-12-25 11:55:37 -06:00
PhoneDroid f6acaa8d4c [ Build ]: Update SPDX License Identifiers 2025-12-25 11:51:30 -06:00
PhoneDroid eeda64c87b [ TemplatePyMod ]: Update SPDX License Identifiers 2025-12-25 11:49:35 -06:00
marioalexis 2d531cc21b Fem: Allow clipping plane in edit mode 2025-12-25 09:19:45 +01:00
marioalexis f44af0929f Fem: Add electrostatic concentrated load 2025-12-25 09:18:57 +01:00
Krzysztof 47d1913544 Core: Extend completer popup list in 'Expression editor', fix size and position adjustment (#25242)
* Core: Fix completer popup adjustment after 'Tab' pressing
Completer popup in Expression Editor is now positioned and sized after pressing 'Tab'. This was missing when feature was added.

* Core: Extend completer popup list to up 20 elements or up to screen edge
Completer popup will now show up to 20 elements or will be limited to screen edge; if limited < 3 rows, popup will be displayed over cursor.

* Core: Fix completer wrapping on secondary screens

* Core: Fix completer positioning when includes long entries

* Core: Fix linter complaints
2025-12-25 09:11:00 +01:00
captain0xff 5cc05a1ab2 Gui: fix linear dragger increments when the multFactor is set 2025-12-25 09:10:27 +01:00
PhoneDroid 86e38348fd [ Dialogs ]: Update SPDX License Identifiers 2025-12-24 22:07:01 -06:00
PhoneDroid 55452aa2ae [ Language ]: Update SPDX License Identifiers 2025-12-24 22:05:23 -06:00
PhoneDroid ca9d9a7a3d [ Inventor ]: Update SPDX License Identifiers 2025-12-24 22:05:07 -06:00
Dimitris75 99a4a98cb3 Fix Linear and Angular Deflection Values
Fix Linear and Angular Deflection Values
2025-12-25 00:16:21 +02:00
Roy-043 4fe0dff1bc Draft: array task panels: add workaround for Building US unit system
Fixes #26276.
2025-12-23 22:01:11 -06:00
Roy-043 5297493a65 BIM: fix AttributeError when snapping for window placement 2025-12-23 21:44:07 -06:00
Rodrigo Olaya Moreno 345a656125 Fix RGB rounding bug in material appearance editor (#26134)
* Fix RGB rounding bug in material appearance editor
* Update code to use color
* getColorHash no longer needs range
2025-12-23 20:20:16 -06:00
Chris eb61ee36a6 sketcher: fix issue #25992 keep snapped position when releasing mosue for updated sketch points (#26102)
* sketcher: fix issue #25992 keep snapped position when releasing mosue for updated sketch points

* Update src/Mod/Sketcher/Gui/ViewProviderSketch.cpp

Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>

---------

Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>
2025-12-23 20:06:51 -06:00
sliptonic 065fea473f CAM: Fix pure vertical linking move (#26195) 2025-12-23 12:19:32 -06:00
sliptonic a139cef80f Merge pull request #26316 from tarman3/millfacing_icon
CAM: MillFacing - Fix icon active state
2025-12-23 10:58:30 -06:00
sliptonic 2a6e3f8fbe Merge pull request #26413 from MTronics/issue_#26343_CAM_relation_to_stock_gets_lost
Issue #26343: CAM Tasks panel ignores selected Stock
2025-12-23 10:21:45 -06:00
timpieces a2dabd42e0 MacOS: Disable actions while file dialogs are open (#26169)
- Any action part of the application menu will trigger based on shortcut
  when a native file dialog is open
- Another way to fix this is to switch out the application menu, but
  afaict it requires writing native objective-c code. I think that's too
  much complexity just to get cmd+c/cmd+v in these file dialogs
- For now, just disable the actions so that select-all, rotate-left, etc
  don't trigger when pressed in these dialogs
- I've implemented an RAII wrapper to disable this. It should take
  pointers which should be fine because all of these dialog calls are
  blocking (so in principle nothing can change underneath).

I'm quite sure this won't have any adverse effects on other platforms,
but will need help from other developers to test in case.
2025-12-23 09:18:08 -06:00
sliptonic 5124ee33c6 CAM: fix tolerance issue with hole detection (#26404) 2025-12-23 09:12:52 -06:00
sliptonic 2d37220efb Merge pull request #26409 from Connor9220/ToolbitsUnitsMigration
CAM: Add migration for Toolbit Units property
2025-12-23 09:08:06 -06:00
Roy-043 d93da36b41 BIM: ifc_tools.py fix handling of IfcGridAxis
Fix errors found after this linter warning:
https://github.com/FreeCAD/FreeCAD/pull/26219/changes#diff-2f58fe8ffd31a6d9302296668f6280d27d696e1507b259cc42fde224ef10da0eL759
2025-12-23 14:04:46 +00:00
pre-commit-ci[bot] 1763f46abf [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2025-12-23 12:07:53 +00:00
MTronics 3a7177764e Issue #26343: CAM Tasks panel ignores selected Stock
The current code in \src\Mod\CAM\Path\Main\Gui\Job.py (line 719) ignores selected stock selections. In case of e.g. cloned stock objects it defaults to the first item in the combolist, showing a wrong stock selection.

The cause lies in comparing different strings to find a label match, but one string object is generic (short name) while the other one has a suffix created during the clone process. The strings never match and the ridgid string comparison fails. I recommend using a partial (needle in haystack) string comparison.
2025-12-23 12:48:14 +01:00
Billy Huddleston 88a28f64c5 CAM: Add migration for Toolbit Units property
This PR adds migration for toolbit units by automatically infering the
Units (Metric/Imperial) from toolbit parameter strings and sets the
Units property if missing. It adds a utility function to detect units
from JSON. This is done at the JSON level during migration to ensure
that all toolbits have the correct Units property set.

src/Mod/CAM/Path/Tool/toolbit/migration.py:
- Infer Units from parameter strings if not set during migration
- Set Units property and log inference
- Refactor migration logic for clarity and reliability

src/Mod/CAM/Path/Tool/toolbit/models/base.py:
- Use Path.Log.debug instead of print when adding Units property

src/Mod/CAM/Path/Tool/toolbit/util.py:
- Add units_from_json() to infer Metric/Imperial from parameter strings
2025-12-23 00:32:47 -05:00
PaddleStroke d15347d2ad Assembly: Fix deletion of joint references to bodies 2025-12-22 22:08:07 -06:00
timpieces 4567d04547 MacOS: Block shortcuts from overriding text input (#14869)
- It seems that on MacOS (vs other platforms), shortcuts for items in
  the application menu are given 'ultimate' priority, and will even take
  precedence over text inputs
- There is a mechanism in QT (I believe designed with mac in mind) to
  try to 'block' these shortcuts and send it to the focus instead. It's
  'Shortcut Override': https://wiki.qt.io/ShortcutOverride
- Initially I was going to only apply this check when it's a Command
  that overrides a known line-editing shortcut, but I figure it's
  simpler to just always apply it when editing text. I can't really
  imagine a user wanting to use an application shortcut while editing
  text, but if there's some compelling use-case for this then let me know
  and I'll add a further filter.

I'm quite optimistic that this won't have any ill-effects on other
platforms, but I'll need help from others to test this.
2025-12-22 21:39:00 -06:00
sliptonic d2daf0fc20 Merge pull request #22304 from tarman3/taskpanel
CAM: Task panel - Select shapes from several objects
2025-12-22 17:07:37 -06:00
sliptonic 8845c1e256 Merge pull request #23149 from Dimitris75/OCL-Adaptive
CAM: Add OCL Adaptive Algorithm to Waterline Operation
2025-12-22 16:47:54 -06:00
sliptonic 9b570424d1 Merge pull request #25049 from phaseloop/v-routing
CAM: improved VCarve routing using "virtual edge backtracking"
2025-12-22 16:44:13 -06:00
sliptonic 4a1b74cf86 Merge pull request #24819 from tarman3/copyOp
CAM: OperationCopy - Allow for all and Recursive copy Dressup
2025-12-22 16:41:36 -06:00
sliptonic 326d423501 Merge pull request #24872 from tarman3/toggle_operation
CAM: ToggleOperation - Allow for Job and Operations group
2025-12-22 16:41:05 -06:00
wandererfan 35d4a849ef [TD]fix handling of non-standard page sizes 2025-12-22 18:46:32 +01:00
marbocub 244282f855 Fix rotation expression errors in handleLegacyTangentPlaneOrientation() (#26058)
* Fix rotation expression handling

- Make added rotation angle unit the same as the original expression unit
- Keep rotated angle expressions within the accepted [-180, +180] range
2025-12-22 11:18:00 -06:00
Kacper Donat 8c399e1fd0 PartDesign: Revolution - add FuseOrder
In older versions of FreeCAD the boolean order was base + result. After
TNP mitigation the order was changed to be result + base. For the
resulting shape that does not matter, but order of edges can differ if
arguments are in a different order.

This can impact refine algorithm which may pick other face as the base
one and result in a differnt shape after refining. This commit restores
previous order. For most files it should not make any difference, but it
may fix some older files.

To support all cases we introduce FuseOrder compatibility property that
will be set to FeatureFirst for files saved with 1.0 to preserve
behavior.
2025-12-22 11:17:27 -06:00
wandererfan 04e2d631bb [TD]fix tearing of page edges 2025-12-22 11:16:15 -06:00
Roy-043 3a5f5d70ee Part: fix Part_EditAttachment unitless input error (#25923) 2025-12-22 11:12:46 -06:00
Florian Foinant-Willig 7b315e80a7 fix %r format spec 2025-12-22 11:04:47 -06:00
Kacper Donat febfd65e59 Gui: Ensure that QuantitySpiBox handles expression properly 2025-12-22 11:00:07 -06:00
Yash Suthar 60bd277d7a UI: Fix select all instances of an object in the tree
Signed-off-by: Yash Suthar <yashsuthar983@gmail.com>
2025-12-22 15:01:24 +01:00
marbocub 176ef6da4e Sketcher: add reverse mapping correction to Carbon Copy (#25745)
* Sketcher: add reverse mapping correction to Carbon Copy

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

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

* Replace M_PI with std::numbers::pi

* Replace vector initialization with Base::Vector3d::UnitX/UnitY, apply suggestions from code review

Co-authored-by: Kacper Donat <kadet1090@gmail.com>

* Fix guard clause logic, apply suggestions from code review

* Replace std::numbers::pi with pi via `using std::numbers`

* Fix issues reported by the linter

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Kacper Donat <kadet1090@gmail.com>
2025-12-22 15:00:49 +01:00
chris 46066e1cca partdesign: pd: fix for issue #25794 2025-12-22 14:58:07 +01:00
Chris 452f9b2087 Part Design: Add sketch sub element names for refs in revolutions (#26227)
* part design: partdesign: pd: fix regression issue #26223 add sketch sub element names for refs in revolutions

* refractor code to remove else blocks as every condition has a return statement, make lsp happy
2025-12-22 14:56:53 +01:00
Alfredo Monclus d9e0fd6251 PartDesign: fix hole clearance not appearing in the taskpanel when switching type 2025-12-22 14:56:09 +01:00
Alfredo Monclus 6729540a78 PartDesign: fix thread depth not shown in taskpanel 2025-12-22 14:55:45 +01:00
Chris Hennes 76bd68e672 PD: Fix missing silent mode check in GetTopoShapeVerifiedFace
Also ensure that all calls to this method actually verify the result.
2025-12-22 14:34:25 +01:00
Furgo 7665675de9 BIM: incremental UX improvements, iteration 1 (#25147) 2025-12-22 13:34:56 +01:00
Kacper Donat 78a6891dae Gui: Remove shortcuts for overlay toggles
Using these commands by mistake can result in broken interface and the
shortcuts are way too easy to hit by mistake. The feature is rarely (if
at all) used - so there is no need to have easy to hit shortcuts.
2025-12-22 13:09:15 +01:00
Kacper Donat 4d712f44c2 PartDesign: Chamfer - migrate Size and Size2 for older files (#26137)
* PartDesign: Chamfer - migrate Size and Size2 for older files

* Apply suggestions from code review

Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>

---------

Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>
2025-12-22 11:52:55 +00:00
freecad-gh-actions-translation-bot 8b7ec488f0 Update translations from Crowdin 2025-12-22 12:40:21 +01:00
Louis Gombert 3601161d80 Part: clean mesh before adding triangulation in setupCoinGeometry
Calling BRepMesh_IncrementalMesh repeatedly would accumulate BRep_CurveRepresentation instances attached to the BRep_TEdges of the shape. We now clean added triangulations before adding a new one, which improves performance in the long run.

Co-authored-by: Kacper Donat <kadet1090@gmail.com>
2025-12-22 12:01:18 +01:00
Roy-043 0af22943b2 BIM: fix deletion of BuildingPart in strict IFC mode (#26219)
* BIM: fix deletion of BuildingPart in strict IFC mode

Add `sg = FreeCADGui.ActiveDocument.ActiveView.getSceneGraph()` to `onDelete`.

* BIM: fix deletion of BuildingPart in strict IFC mode

Explicitly call `obj.ViewObject.Proxy.attach(obj.ViewObject)`.

* BIM: fix deletion of BuildingPart in strict IFC mode

In `ifc_vp_buildingpart` call `attach` from `ArchBuildingPart.ViewProviderBuildingPart`.
2025-12-21 20:16:17 -06:00
Chris 4cd81136b6 Sketcher: Allow live preview of sketch placement (#26033)
along with unit tests
2025-12-21 17:34:30 +01:00
Furgo 0193b1776d BIM: Initialize SketchArch variable before use (#26336) 2025-12-21 10:36:35 +01:00
Furgo 69de78e22d BIM: fix lock removal of Sill property 2025-12-21 10:27:12 +01:00
Furgo bdea3d105f BIM: rename ArchWindow's Sill property to SillHeight and handle one-w… (#26277)
* BIM: rename ArchWindow's Sill property to SillHeight and handle one-way migration

* BIM: properly remove the locked "Sill" property
2025-12-20 22:26:52 +01:00
Louis Gombert cead907a57 SVG export: improve performance (#26149)
* SVG export: use a set to match edges instead of a list

Lookup in edge list becomes O(1), significantly improving SVG export speed

* [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>
2025-12-20 22:23:55 +01:00
tarman3 df3f311813 CAM: Array - Refactor class PathArray 2025-12-20 21:03:06 +02:00
tarman3 4f8ed3b1a0 CAM: Path.Post.Utils.splitArcs() - Fix zero deflection 2025-12-20 20:02:29 +02:00
tarman3 daf9b60f27 CAM: Job - Fix setCenterOfRotation() 2025-12-20 19:56:00 +02:00
sliptonic 1b4026ebf0 Merge pull request #26217 from tarman3/array_icon
CAM: Array - Fix ViewProviderArray and icons
2025-12-20 10:11:02 -06:00
tarman3 59aa295ec6 CAM: Array - Fix ViewProviderArray and icon 2025-12-20 10:45:20 +02:00
tarman3 efdabea4e0 CAM: MillFacing - Fix icon active state 2025-12-20 10:17:56 +02:00
Chris Hennes c423e8de08 Addon Manager: Update to 2025.12.19
Minor bug fixes and translation update.
2025-12-20 06:58:03 +01:00
Christoph Moench-Tegeder 4f4f4425aa Include sys/sysctl.h on FreeBSD when using sysctl()
The ApplicationDirectories::findHomePath() on BSD uses sysctl()
to find the path to the running executable. On FreeBSD, we need
to include sys/sysctl.h for that - and as it is not included anywhere
else, add it to the includes directly in front of this function,
with a suitable ifdef.
2025-12-19 20:55:52 -06:00
Roy-043 348eef644b Part: fix Part_EditAttachment nesting handling (#26298)
* Part: fix Part_EditAttachment nesting handling

Fixes #26264.

The previous 'fix' (#25887) did not consider that the object to-be-attached may not be in the global space.

The code in this PR has been tested on the forum:
https://forum.freecad.org/viewtopic.php?p=862968#p862968

* [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>
2025-12-19 20:40:37 -06:00
VM4Dim 7cd88534b5 Gui: Fix non-Latin groupName (#26285) 2025-12-19 18:53:16 -06:00
Kacper Donat 87b257546f Gui: Wrap strings with QStringLiteral 2025-12-19 13:14:25 -06:00
chris 22552848fd sketcher: fixes issue #26167 no polygon distort when repositioning / constraining 2025-12-19 11:22:20 +01:00
Yash Suthar dbd2bade1e Part: added floating point fallback in PropertyLinks::_updateElementReference
Signed-off-by: Yash Suthar <yashsuthar983@gmail.com>
2025-12-19 10:52:26 +01:00
sliptonic d48073fbbf Merge pull request #26260 from Connor9220/UpdateTSPSolver
CAM: Add open-route optimizations to point-based TSP solver
2025-12-18 16:11:32 -06:00
Syres916 26cc33ecfb [Core] Fix macro path append to sys.path 2025-12-18 13:19:21 -06:00
Kacper Donat b5d60baa68 Stylesheets: Fix separators appearance 2025-12-18 19:47:51 +01:00
Billy Huddleston a7b6078b1d CAM: Add open-route optimizations to point-based TSP solver
Improves the point-based TSP solver to match tunnel solver behavior
for open routes (no endpoint constraint). Now applies 2-opt and
relocation optimizations that allow reversing or relocating segments
to the end of the route, resulting in better path optimization when
the ending point is flexible. Now links tsp_solver with
Python3::Python and uses add_library for compatibility with FreeCAD
and Fedora packaging.

src/Mod/CAM/App/tsp_solver.cpp:
- Add optimization limit variables for controlled iteration
- Add 2-opt and relocation optimizations for open routes
- Use Base::Precision::Confusion() for epsilon values
- Track last improvement step for efficient loop control

src/Mod/CAM/App/CMakeLists.txt:
- Switch tsp_solver from pybind11_add_module to add_library
- Link tsp_solver with pybind11::module and Python3::Python
- Update include directories for consistency
2025-12-18 12:15:22 -05:00
PaddleStroke 0c1ef0c77f Measure: getPlacement const (#26216)
* Measure: getPlacement const

* Update MeasureBase.h

* Update MeasureBase.cpp

* Update MeasureArea.h

* Update MeasureArea.cpp

* Update MeasureLength.h

* Update MeasurePosition.cpp

* Update MeasureLength.cpp

* Update MeasureRadius.cpp

* Update MeasurePosition.cpp

* Update MeasurePosition.h

* Update MeasureRadius.h

* Update MeasurePosition.h
2025-12-18 14:04:32 +01:00
Kacper Donat fe3dc9f06a Compiler warning cleanup (#26229)
* App: Compiler warning cleanup

* Gui: Compiler warning cleanup

* Assembly: Compiler warning cleanup

* Measure: Compiler warning cleanup

* Sketcher: Compiler warning cleanup

* TechDraw: Compiler warning cleanup

* PartDesign: Compiler warning cleanup
2025-12-18 07:50:26 +01:00
freecad-gh-actions-translation-bot 6c6cff7322 Update translations from Crowdin 2025-12-17 21:10:10 -06:00
Chris Hennes 0ba75a7573 PartDesign: Compiler warning cleanup 2025-12-17 11:08:38 -06:00
Chris Hennes c7c4c6f0cc TechDraw: Compiler warning cleanup 2025-12-17 11:08:38 -06:00
Chris Hennes 50f029edd4 Sketcher: Compiler warning cleanup 2025-12-17 11:08:34 -06:00
Chris Hennes 36332bf9ca Measure: Compiler warning cleanup 2025-12-17 11:08:22 -06:00
Chris Hennes 04a9c1e7b0 Assembly: Compiler warning cleanup 2025-12-17 11:08:12 -06:00
Chris Hennes 0416a5bc0b Gui: Compiler warning cleanup 2025-12-17 11:07:55 -06:00
Chris Hennes 55a55725eb App: Compiler warning cleanup 2025-12-17 10:41:27 -06:00
Furgo e147e5a260 Refactor problem report template for improved previews
Reorder fields so that the problem description will be rendered first in previews.
2025-12-17 11:01:02 +01:00
pre-commit-ci[bot] be6c633d62 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2025-12-16 20:57:34 +00:00
Dimitris75 a840988ddb Refactor bounding box and tool path limit calculations
Refactor bounding box calculations for OCL Adaptive algorithm to improve clarity and maintainability.
2025-12-16 22:55:22 +02:00
pre-commit-ci[bot] 5b0cdb2b6d [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2025-12-16 20:23:12 +00:00
Dimitris75 93410b264a Override deflection values for OCL Adaptive algorithm
Added logic to override deflection values for OCL Adaptive algorithm to improve topology stability.
2025-12-16 22:18:47 +02:00
PaddleStroke 8fd81d4109 Assembly: Ball drag mode. (#26222) 2025-12-16 19:08:50 +01:00
marioalexis 0f148f6e63 Base: Add millitesla unit 2025-12-16 14:26:31 -03:00
marioalexis bfb0efd5f9 Base: Insert SPDX specifier in parser script 2025-12-16 14:26:31 -03:00
marioalexis e5e1729c35 Fem: Add magnetic shielding example 2025-12-16 14:26:31 -03:00
marioalexis ac878c5eeb Fem: Add magnetic flux density boundary condition 2025-12-16 14:26:31 -03:00
pre-commit-ci[bot] f9bb30217b [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2025-12-16 15:39:06 +00:00
Dimitris75 67df5bd709 Use dynamic LinearDeflection and AngularDeflection values
Remove Temporary values from Mesh
2025-12-16 17:37:04 +02:00
sliptonic a13502dccb Merge pull request #26205 from Connor9220/PreserveTSPTunnelExtraData
CAM: Update TSP tunnel solver
2025-12-16 09:31:14 -06:00
Dimitris75 b2ff8c5edc Merge branch 'OCL-Adaptive' of https://github.com/Dimitris75/FreeCAD into OCL-Adaptive 2025-12-16 14:27:21 +02:00
Dimitris75 a6bc504a2a Add OCL Adaptive in Tooltip
Add OCL Adaptive algorithm in UI Tooltip
2025-12-16 14:27:15 +02:00
Saksham Malhotra b7735044c4 PartDesign: move AllowCompound to Base property group (#26180) 2025-12-15 21:45:29 -06:00
Kacper Donat 68f2c6f864 chore: Add code quality problem report form 2025-12-15 21:18:34 -06:00
Kacper Donat a0356796ac Gui: Fix segfault in Safe Mode
This fixes segfault that was caused by changing settings in
FirstStartWidget that triggered change event on not fully intialized
StartView.

It is quick and dirty fix that just disables handling of the event
causing segfault until widget is fully ready. The correct solution would
be to remove the logic that changes settings from the widget (as it
should not be there) and instad move it to another place in pipeline.
This would be however much more work and segfault should be fixed ASAP.
2025-12-15 21:06:51 -06:00
Billy Huddleston 646b0f4492 CAM: Update TSP tunnel solver
Update TSP tunnel solver to match revised Pythonlogic, including
improved early exit, open-ended route handling, and performance tweaks.
Also ensure extra data in tunnel dictionaries is preserved through the
C++/Python interface and add a test for passthrough of extra keys.

src/Mod/CAM/App/tsp_solver.cpp:
- Refactor optimization loop to use lastImprovementAtStep and limit
variables
- Add special handling for open-ended routes (no end point)
- Change epsilon to 10e-6 for consistency with Python
- Cache distance calculations for relocation step

src/Mod/CAM/App/tsp_solver_pybind.cpp:
- Preserve extra keys from input tunnel dicts in output
- Set tunnel index for passthrough

src/Mod/CAM/CAMTests/TestTSPSolver.py:
- Add test to verify extra data in tunnel dicts is preserved through
TSP solver
- Print extra data for debugging
2025-12-15 21:50:51 -05:00
pre-commit-ci[bot] ccf0bdbce0 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2025-12-15 23:59:54 +00:00
Dimitris75 96c23f1968 Simplify code and UI
Simplify code and UI
2025-12-16 01:57:45 +02:00
Billy Huddleston 04df03cea1 CAM: Preserve extra tunnel data through TSP solver
Ensures that all extra keys in tunnel dictionaries are preserved after
TSP solving by copying the original input dict and updating solver
results. Adds a dedicated test to verify passthrough of extra data and
prints extra keys for debugging.

src/Mod/CAM/App/tsp_solver_pybind.cpp:
- Copy original tunnel dict and update with solver results to preserve extra keys

src/Mod/CAM/CAMTests/TestTSPSolver.py:
- Add test_09_tunnels_extra_data_passthrough to verify extra data preservation
- Print extra tunnel data in print_tunnels for easier debugging
2025-12-15 16:32:03 -05:00
sliptonic d116764dc3 CAM: Avoid bosses when pocketing. (#24723) 2025-12-15 12:29:28 -06:00
tarman3 3426672ccd CAM: Slot - Clear path if can not create slot 2025-12-15 20:21:16 +02:00
sliptonic 12355f37e9 Merge pull request #25826 from tarman3/pathcommands_qtcore
CAM: PathCommands - Remove unused import QtCore
2025-12-15 11:59:37 -06:00
sliptonic e1e8323dc1 Merge pull request #25839 from tarman3/slot_remove_0
CAM: Slot - Remove .0
2025-12-15 11:58:59 -06:00
sliptonic 44a5960d57 Merge pull request #26123 from Connor9220/AddCommandAnnotationsTests
CAM: Add comprehensive tests for Command constructor annotations
2025-12-15 11:57:28 -06:00
sliptonic bf3a471948 Merge pull request #24726 from Connor9220/TwoOptTSPSolver
CAM: 2-Opt TSP solver
2025-12-15 11:55:20 -06:00
Chris Hennes 10ed34bd4c Gui: Correct UTF-8 support for property names 2025-12-15 18:26:51 +01:00
Roy-043 2efd63614f BIM: ArchReference: fix coin node handling
Fixes #25772.
2025-12-15 17:24:00 +00:00
Chris Hennes 3208b6de5f PD: Don't warn about Midplane on document load 2025-12-15 18:22:31 +01:00
Roy-043 1c8df498f3 BIM: ArchReference: handle transparency-alpha switch
The 'old' DiffuseColor comes in 2 flavors. In v0.21.2 it stores transparency values. In v1.0.2 and v1.1 it stores alpha values. The ArchReference code should handle both. DiffuseColor is still used by BuildingParts in v1.0.2 and v1.1.

The solution is a bit hacky: if 100% transparency occurs we assume we are actually dealing with alpha values.
2025-12-15 17:21:29 +00:00
Chris Hennes 5ba7f207ab PD: Correct is-datum-in-body check 2025-12-15 18:20:04 +01:00
Roy-043 15bb0ee896 BIM: use optimalBoundingBox in getCutVolume 2025-12-15 17:19:56 +00:00
drwho495 88b5cde45f Implement Fix
Switch from checking child tag to checking the materTag
2025-12-15 11:17:42 -06:00
Roy-043 e6e285315c Draft: make Draft_AnnotationStyleEditor dialog wider
Increase AnnotationStyleEditorWidth from 450 to 600 to mitigate #25983.
2025-12-15 11:16:28 -06:00
Kacper Donat aefd2592a8 Gui: Respect both content size and minimum width for buttons
This is a hacky fix for https://github.com/FreeCAD/FreeCAD/issues/23607

Basically after widget is shown or polished we enforce it's minimum size to at
least cover the minimum size hint - something that QSS ignores if min-width is
specified.
2025-12-15 10:17:34 -06:00
Chris Hennes 16032ae34c Merge pull request #25914 from AjinkyaDahale/sk-fix-25281
Sketcher: Handle angle constraint on sketchobject changes
2025-12-15 10:15:13 -06:00
theo-vt 29eeab3624 Sketcher: Do not autoscale if there are blocked geometries 2025-12-15 09:20:20 -06:00
Kacper Donat fc93004c89 Gui: Improve transform UI responsivness
This introduces much faster CenterOfMassProvider#supports method that
can be used as cheap pre-check to see if the object supplied could have
the center of mass and so delay the domputation to a moment where it is
actually needed.
2025-12-15 09:18:27 -06:00
tarman3 7c941987a4 CAM: Profile - Limit value NumPasses 2025-12-15 14:41:22 +02:00
Billy Huddleston 095cdb14a7 CAM: Add comprehensive TSP tunnel solver tests and wrapper function
Added extensive test coverage for the TSP tunnel solver including linear
 tunnels, pentagram diagonals, and complex wire geometries with various
 constraint combinations. Introduced a Python wrapper function for
 tunnel sorting that integrates with the C++ solver.

src/Mod/CAM/CAMTests/TestTSPSolver.py:
- Renumbered existing tests to run in sequential order
(test_01_simple_tsp, test_02_start_point, etc.)
- Added print_tunnels() helper function for displaying tunnel
information with original indices
- Added test_06_tunnels_tsp: Tests 7 linear tunnels with varying
lengths, connectivity, and flipping behavior
- Added test_07_pentagram_tunnels_tsp: Tests pentagram diagonal tunnels
 with no constraints, start+end constraints, and start-only constraints
- Added test_08_open_wire_end_only: Tests end-only constraint on complex
 wire with 8 tunnels including crossings and diagonals

src/Mod/CAM/PathScripts/PathUtils.py:
- Added sort_tunnels_tsp() wrapper function that interfaces with the C++
tsp_solver.solveTunnels()
- Supports allowFlipping, routeStartPoint, and routeEndPoint parameters
2025-12-14 16:45:51 -05:00
chris 3476562dd7 fem: attempt to resolve issue #19798 2025-12-14 12:15:35 -06:00
Yash Suthar 8413922e52 Core: fix "Save Image" giving dark area as compare to viewport
Signed-off-by: Yash Suthar <yashsuthar983@gmail.com>
2025-12-14 14:49:58 +01:00
Kacper Donat bf697ca710 Gui: Use largest possible marker if needed
This is a quick and dirty fix for https://github.com/FreeCAD/FreeCAD/issues/22010

Basically if we want to use a bigger marker size than available, we use the biggest one
available. This is not a good way to fix the issue - we should ensure that the marker
size that the user requests is actually available - this, however, requires more
significant changes to the code.
2025-12-13 16:23:59 -06:00
Billy Huddleston d940c499b7 CAM: Add TSP tunnel solver with flipping and Python bindings
Introduce TSPTunnel struct and implement TSPSolver::solveTunnels
for optimizing tunnel order with support for flipping and start/end points.
Expose the new functionality to Python via pybind11, returning tunnel
dictionaries with flipped status.

src/Mod/CAM/App/tsp_solver.cpp:
- Add solveTunnels implementation for tunnel TSP with flipping and route endpoints

src/Mod/CAM/App/tsp_solver.h:
- Define TSPTunnel struct
- Declare solveTunnels static method in TSPSolver

src/Mod/CAM/App/tsp_solver_pybind.cpp:
- Add Python wrapper for solveTunnels
- Expose solveTunnels to Python with argument parsing and result conversion
2025-12-13 10:59:47 -05:00
xtemp09 df6d148a85 [GUI] Rename Cancel ‘Close’ in Add Property dialog 2025-12-13 15:19:41 +01:00
Furgo d55d8d1dac BIM: Report command MVP (#24078)
* BIM: BIM Report MVP

* BIM: add Arch.selectObjects() API call and tests

* BIM: adopted ArchSchedule spreadsheet update and linking patterns

* BIM: SELECT with dynamic headers and dynamic data population

* BIM: fix deletion, dependencies, and serialization issues

* BIM: transition from individual query to multiple-query statements

* BIM: Mostly fix serialization issues

* BIM: Report editor UI/UX improvements

- Make edits directly on table (Description field only, for now)
- Sync table edits with query editor (Description field only, for now)
- Fix Property group name for spreadsheet object
- Add tooltips for all task panel widgets
- Put Description input and label on the same row
- Edit statement is now a static title
- Open report editor upon creation
- Remove overview table's redundant edit button
- Put report query options in a box
- Open spreadsheet after accepting report changes

* BIM: Aggregarion and grouping - implement GROUP BY with COUNT(*)

* BIM: Aggregation and grouping - implement SUM, MIN, MAX functions

* BIM: Aggregation and grouping - implement validation

* BIM: add reporting presets support

* BIM: align description and query preset inputs vertically

* BIM: write units on their own spreadsheet cell

* BIM: update test suite to new SQL engine behaviour

* BIM: fix various bugs: return values should not be stringized, non-grouped query with mixed extractors, handle nested properties

* BIM: expand Report test suite, fix property count vs count all bug

* BIM: add report engine SQL's IN clause support

* BIM: enable running Report presets tests from the build directory

* BIM: make spreadsheet more useful for analysis, units on headers

* BIM: update BIM Report icons

* BIM: Add key option columns to report overview table

* BIM: add syntax highlighting support to report query editor

* BIM: Add lark build dependency for SQL parser generator

* BIM: Install the generated parser

* BIM: implement TYPE() function

* BIM: simplify function registry, make it OOP

* BIM: add CHILDREN function

* BIM: improve SQL engine error descriptions

* BIM: Implement ORDER BY clause

* BIM: Implement column aliasing (AS...)

* BIM: improve error reporting to pinpoint exact token names

* BIM: implement CONCAT, LOWER, UPPER functions. Improve exception handling

* BIM: refactor to improve initialization readability and maintenance

* BIM: Improve query editor syntax highlighting

* BIM: Address CodeQL warnings

* BIM: Enable scalar functions in WHERE clause and refactor transformer

- Enable the use of scalar functions (e.g., `LOWER`, `TYPE`) in `WHERE` clause comparisons.
- Refactor the Lark transformer to correctly handle `NUMBER`, `NULL`, and `ASTERISK` terminals using dedicated methods.
- Refactor error handling to raise a custom `BimSqlSyntaxError` exception instead of returning values on failure.
- Improve syntax error messages to be more specific and user-friendly by inspecting the failing token.
- Fix regressions in `AggregateFunction` and `TypeFunction` handling that were introduced during the refactoring.
- Update the test suite to assert for specific exceptions, aligning with the new error handling API.

* BIM: Implement arithmetic operations in SELECT clause

- Update grammar with `expr`, `term`, and `factor` rules to support operator precedence.
- Introduce `ArithmeticOperation` class to represent calculations as a recursive tree.
- Add transformer methods to build the calculation tree from the grammar rules.
- Implement recursive evaluation that correctly normalizes `Quantity` and `float` types before calculation.

* BIM: Add CONVERT() function for unit conversions

- Implement a new ConvertFunction class to handle unit conversions in the SELECT clause.
- Leverage the core Quantity.getValueAs() FreeCAD API method to perform the conversion logic.
- Add a unit test to verify both successful conversions and graceful failure on incompatible units.

* BIM: add self-documenting supported SQL syntax helper

* BIM: document internal and external API functions

* BIM: Finalize and rename public ArchSql API, update all consumers

- Rename public API functions for clarity and consistency
  (run_query_for_objects -> select, get_sql_keywords -> getSqlKeywords,
  etc.).
- Establish Arch.py as the official API facade by exposing all public
  SQL functions and exceptions via a safe wildcard import from ArchSql,
  governed by __all__.
- Refactor all consumers (ArchReport.py, bimtests/TestArchReport.py) to
  use the new function names and access the API exclusively through the
  Arch facade (e.g., Arch.select).
- Finalize the error handling architecture:
  - Arch.select now logs and re-raises exceptions for consumers to
    handle.
  - Arch.count remains "safe," catching exceptions and returning an
    error tuple for the UI.
- Refactor the test suite to correctly assert the behavior of the new
  "unsafe" (select) and "safe" (count) APIs, including verifying
  specific exception messages.

* BIM: add results preview on demand on the query editor

* BIM: add documentation quick reference button

* BIM: Handle query errors gracefully in Report preview UI

Refactor the SQL engine's error handling to improve the Report preview
UI. Invalid queries from the "Preview Results" button no longer print
tracebacks to the console. Instead, errors are now caught and displayed
contextually within the preview table, providing clear feedback without
console noise.

- `ArchSql.select()` no longer logs errors to the console; it now only
  raises a specific exception on failure, delegating handling to the
  caller.
- The `ReportTaskPanel`'s preview button handler now wraps its call to
  `Arch.select()` in a `try...except` block.
- Caught exceptions are formatted and displayed in the preview table
  widget.
- Add new unit test

* BIM: consolidate internal API into a more semantically and functionally meaningful function

* BIM: Implement two-phase execution for SQL engine performance

Refactors the ArchSql engine to improve performance and internal API
semantics. The `Arch.count()` function, used for UI validation, now
executes faster by avoiding unnecessary data extraction.

This is achieved by splitting query execution into two phases. The first
phase performs fast filtering and grouping (`FROM`/`WHERE`/`GROUP BY`).
The second, slower phase processes the `SELECT` columns. The
`Arch.count()` function now only runs the first phase, while
`Arch.select()` runs both.

- Introduces `_run_query(query_string, mode)` as the mode-driven
  internal entry point for the SQL engine
- The `SelectStatement` class is refactored with new internal methods:
  `_get_grouped_data()` (Phase 1) and `_process_select_columns()`
  (Phase 2).
- `Arch.count()` now uses a fast path that includes a "sample execution"
  on a single object to correctly validate the full query without
  performance loss.
- The internal `execute()` method of `SelectStatement` is now a
  coordinator for the two-phase process.

* BIM: Implement autocompletion in Report SQL editor

Introduces an autocompletion feature for the SQL query editor in the BIM
Report task panel. The completer suggests SQL keywords, functions, and
property names to improve query writing speed and accuracy.

- Adds a custom `SqlQueryEditor` subclass that manages all
  autocompletion logic within its `keyPressEvent`.
- The completion model is populated with static SQL keywords and
  functions, plus all unique top-level property names dynamically
  scanned from every object in the document.
- A blocklist is used to filter out common non-queryable properties
  (e.g., `Visibility`, `Proxy`) from the suggestions.
- The editor manually calculates the completer popup's width based on
  content (`sizeHintForColumn`) to resolve a Qt rendering issue and
  ensure suggestions are always visible.
- The first suggestion is now pre-selected, allowing a single `Tab`
  press to accept the completion.

* BIM: remove unused import

* BIM: support SQL comments in queries

* BIM: support non-ASCII characters in queries

* BIM: Allow ORDER BY to accept a comma-separated list of columns for multi-level sorting.

* BIM: fix two-way overview/editor sync

* BIM: refactor to simplify editor modification events

* BIM: add tooltips to overview table

* BIM: add tooltips to query editor, enrich syntax data with signature and snippets

* BIM: implement PARENT function

* BIM: Enable property access on SQL function results

Previously, the SQL engine could only access properties directly from
the main object in a given row. This made it impossible to query
attributes of objects returned by functions, such as getting the name of
a parent with PARENT(*). This commit evolves the SQL grammar to handle
chained member access (.) with correct operator precedence. The parser's
transformer and execution logic were updated to recursively resolve
these chains, enabling more intuitive queries like SELECT
PARENT(*).Label and standard nested property access like Shape.Volume.

* BIM: refactor function registration, internationalize API metadata

* BIM: remove outdated Report alias

* BIM: refactor selectObjects to use latest API, move implementation to ArchSql

* BIM: improve friendly token names for error reporting

* BIM: implement chained functions e.g. PARENT(*).PARENT(*)

* BIM: add further tests for property access, fix bug with non-literal AS clause argument

* BIM: Implement full expression support for GROUP BY

The SQL engine's GROUP BY clause was previously limited to simple
property names, failing on queries that used functions (e.g., `GROUP BY
TYPE(*)`). This has been fixed by allowing the SQL transformer and
validator to correctly process function expressions.

The `SelectStatement.validate()` method now uses a canonical signature
to compare SELECT columns against GROUP BY expressions, ensuring
correctness for both simple properties and complex functions.

New regression tests have also been added to validate `GROUP BY`
functionality with chained functions (PPA) and multiple columns.

* BIM: Make arithmetic engine robust against missing properties

Previously, a query containing an arithmetic expression in the `WHERE`
clause would cause a fatal error if it processed an object that was
missing one of the properties used in the calculation.

This has been fixed by making the `ArithmeticOperation` class NULL-safe.
The engine now correctly handles `None` values returned by property
lookups, propagating them through the calculation as per standard SQL
behavior.

As a result, the engine no longer crashes on such queries. It now
gracefully evaluates all objects, simply filtering out those for which
the arithmetic expression cannot be resolved to a valid number. This
significantly improves the robustness of the query engine.

* BIM: Finalize ORDER BY logic and fix query regressions

- The `ORDER BY` clause is now governed by a single, predictable rule:
  it can only refer to column names or aliases that exist in the final
  `SELECT` list. The engine's transformer and execution logic have been
  updated to enforce and correctly implement this, fixing several test
  failures related to sorting by aliases and expressions.
- Updated test suite to align with the new engine rules. Add new
  dedicated unit tests that explicitly document the supported (aliased
  expression) and unsupported (raw expression) syntax for the `ORDER BY`
  clause.

* BIM: Implement backend for pipelined report execution

Adds the backend architecture for multi-step, pipelined queries. The
core SQL engine can now execute a statement against the results of a
previous one, enabling complex sequential filtering.

- The internal `_run_query` function was refactored to be
  pipeline-aware, allowing it to operate on a pre-filtered list of
  source objects.
- A new `execute_pipeline` orchestrator was added to manage the data
  flow between statements, controlled by a new `is_pipelined` flag in
  the `ReportStatement` data model.
- The public API was extended with `selectObjectsFromPipeline` for
  scripting, and `count()` was enhanced to support contextual validation
  for the UI.

Pipelines phase 2

Pipelines phase 3

* BIM: refactor to avoid circular imports

* BIM: Address key CodeQl check errors/notes

* BIM: Refactor Task Panel UI/UX with explicit editing workflow

Refactor the report editor UI to improve usability and prevent data
loss. Editing a statement is now an explicit action, triggered by a new
"Edit Selected" button. This prevents accidental changes and enables a
new transactional workflow with "Save" and "Discard" buttons for each
edit session. A checkbox for "Apply & Next" has been added to streamline
editing multiple statements.

The results preview feature has been redesigned into a self-contained,
closable pane controlled by a "Show Preview" toggle. This pane includes
its own contextual "Refresh" button, reducing UI clutter. All action
button groups have been consistently right-aligned to improve layout and
workflow.

* BIM: Integrate pipeline execution and stabilize UI workflow

Completes the implementation of the pipelined statements feature by
integrating the new backend orchestrator with the ArchReport object. It
also includes a series of critical bug fixes that were discovered during
end-to-end testing, resulting in a more stable user experience.

The primary feature integration consists of refactoring the
_ArchReport.execute method. It now uses the ArchSql.execute_pipeline
generator, enabling the report to correctly process multi-step pipelines
and honor the user-configured data flow.

Severalbugs and regressions were fixed:

- Backend: A major flaw was fixed where FROM-clause functions (like
  CHILDREN) were not pipeline-aware. The engine's GROUP BY validator was
  also corrected to enforce its original, safer design of not supporting
  aliases.
- UI Workflow: A feedback loop that caused the editor cursor to reset
  was resolved. The transactional logic for the Save, Discard, and "Save
  & Add New" actions was corrected to prevent data loss and ensure
  predictable behavior. The Add and Duplicate actions no longer auto-open
  the editor, creating a more consistent workflow.
- UI State: Fixed regressions related to the explicit editing model,
  including incorrect statement loading (Edit Selected) and state
  management when a report is reloaded from a file.

* BIM: add presets manager

* BIM: Fix 'still touched after recompute' bug in some of the tests

* BIM: cleanup tests, fixed presets tests to new presets locations

* BIM: Move test model to its own module for reusability

* BIM: Move GUI tests to their own module

- Disable two of the tests: they pass, but cause a segmentation fault on
  teardown. They need to be investigated before enabling them on CI.

* BIM: fix bug in interpreting CONVERT string from GROUP BY

* BIM: Migrate signal connections from lambdas to Qt slots

Refactors all signal connections in the `ReportTaskPanel` to use the
`@QtCore.Slot()` decorator instead of lambda wrappers.

- Resolves CodeQL warning "Unnecessary lambda".
- Adheres to PySide/Qt best practices for signal/slot handling.
- Improves code clarity by using explicit, named methods for
  connections.
- Prevents potential runtime `TypeError` exceptions by correctly
  managing slot signatures for signals that emit arguments (e.g.,
  `clicked(bool)`).
- Introduces simple slot wrappers where necessary to cleanly separate UI
  event handling from core logic.

* BIM: Address CodeQl warnings

* BIM: Add CHILDREN_RECURSIVE(subquery, max_depth) SQL function to find all descendants of an object set.

- Create internal _get_bim_type and _is_bim_group helpers to remove all Draft module dependencies from the SQL engine.
- Implement a new _traverse_architectural_hierarchy function using a deque-based BFS algorithm to prevent infinite loops.
- The CHILDREN and CHILDREN_RECURSIVE functions now use the new traversal engine.
- The traversal engine now transparently navigates generic groups but excludes them from the results.
- Correct ParentFunction logic to validate containment by checking the parent's .Group list instead of the child's .InList.
- Add unit tests for recursive traversal, depth limiting, and transparent group handling.
- Update test_group_by_multiple_mixed_columns to match the corrected behavior of the TYPE(*) function.

* BIM: Add __repr__ and __str__ for the ArchReport proxy

* BIM: Align report quantity headers with internal units

- Change default `Quantity` headers to use the property's internal unit
  (e.g., `mm`) instead of the user's global preferred unit (e.g., `m`).
- Fixes inconsistency where the header unit (e.g., `m²`) did not match
  the raw data's unit (e.g., `mm²`), making the default behavior
  predictable.
- Implement by parsing `str(Quantity)` as a workaround for the C++
  `Unit::getString()` method not being exposed to the Python API.
- Add a unit test that temporarily changes the global schema to verify
  the fix is independent of user preferences.

* BIM: remove dual import ArchSql and from ArchSql import

* BIM: Fix IfcRole => IfcType

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

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

* CI: add Lark as a build dependency

* BIM: Replace QRegExp with QRegularExpression for regex patterns

QRegExp is no longer available in PySide6. Make the code compatible with
both PySide2/Qt5 and PySide6/Qt6.

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

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

* CI: move lark dependency to pixi's requirements.host

* BIM: Correct numeric comparisons in SQL WHERE clause

Refactor the `BooleanComparison.evaluate` method to handle numeric and
string-based comparisons separately. Previously, all comparisons were
being performed on string-converted values, causing numerically
incorrect results for `Quantity` objects formatted with "smart" units
(e.g., `"10.0 m"` was incorrectly evaluated as less than `"8000"`).

- The `evaluate` method now normalizes `Quantity` objects to their raw
  `.Value` first.
- If both operands are numeric, a direct numerical comparison is
  performed for all operators (`=`, `!=`, `>`, `<`, `>=`, `<=`).
- String-based comparisons (for `like`, or as a fallback for other
  types) are handled in a separate path.
- Add unit test to lock down this behavior.

* BIM: autocompleter improvements

- Add a trailing space when autocompleting the keywords that need it
- Autocomplete multi-word keywords as a unit

* BIM: Improve live validation user experience

- Do not throw syntax error when in the middle of autocompleting a
  keyword
- Introduce typing state and show incomplete query status

* BIM: change double-click action to edit in statements overview

Also allow quick editing the statement description with F2

* BIM: Improve user strings for consistency

* BIM: show count of returned objects in statements table

* BIM: disable preview on invalid queries

* BIM: define slot so that tests can run headless

* BIM: Update unit test to adapt to new behaviour

* [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>
2025-12-13 13:02:13 +00:00
tarman3 cd8ebe10bf CAM: EngraveBase - Tolerance 2025-12-13 10:25:17 +02:00
tarman3 ea7ef0b132 CAM: Tag Dressup - Tolerance 2025-12-13 09:49:31 +02:00
Billy Huddleston b2b9f03086 CAM: Add comprehensive tests for Command constructor annotations
Add detailed test coverage for the new Command constructor that accepts
annotations parameter, including positional and keyword arguments,
string and numeric annotations, empty annotations, and backward
compatibility. Split existing save/restore tests for better granularity.

src/Mod/CAM/CAMTests/TestPathCommandAnnotations.py:
- Added test14-test20 for Command constructor with annotations
- Split test12 into test12 (empty annotations) and test13
(complex annotations) for focused testing
2025-12-12 20:45:02 -05:00
Billy Huddleston 005cbb937d Rewrite TSP solver for improved path optimization and clarity
- Completely re-implemented the TSP algorithm in C++ for better path quality
- Added detailed comments and documentation to clarify each step
- Improved nearest neighbor, 2-opt, and relocation logic
- Enhanced handling of start/end point constraints
- Updated PathUtils.py docstring to accurately describe start point behavior
2025-12-12 19:39:29 -05:00
Billy Huddleston 428948699a Add startPoint and endPoint support to TSP solver and Python wrapper; add tests
- Enhanced the C++ TSP solver to accept optional start and end points, so the route can begin and/or end at the closest point to specified coordinates.
- Updated the Python pybind11 wrapper and PathUtils.sort_locations_tsp to support startPoint and endPoint as named parameters.
- Added a new Python test suite (TestTSPSolver.py) to verify correct handling of start/end points and integration with PathUtils.
- Registered the new test in TestCAMApp.py and CMakeLists.txt for automatic test discovery.
2025-12-12 19:39:28 -05:00
Billy Huddleston f9347c781b Add 2-Opt TSP solver
This update introduces a new C++ 2-Opt TSP solver with Python bindings.

src/Mod/CAM/App/CMakeLists.txt:
- Add build and install rules for the new pybind11-based tsp_solver Python module

src/Mod/CAM/App/tsp_solver.cpp:
- Add new C++ implementation of a 2-Opt TSP solver with nearest-neighbor initialization

src/Mod/CAM/App/tsp_solver.h:
- Add TSPPoint struct and TSPSolver class with 2-Opt solve method

src/Mod/CAM/App/tsp_solver_pybind.cpp:
- Add pybind11 wrapper exposing the TSP solver to Python as tsp_solver.solve

src/Mod/CAM/PathScripts/PathUtils.py:
- Add sort_locations_tsp Python wrapper for the C++ TSP solver
- Use tsp_solver.solve for TSP-based
2025-12-12 19:39:28 -05:00
David Kaufman 5c3e32a42c also use the % symbol for step over percent 2025-12-12 15:38:14 -05:00
David Kaufman f6daab5ed8 use % symbol in min/max helix diameter input fields, instead of the word 'percent' in the label 2025-12-12 15:33:00 -05:00
David Kaufman 5d877d1cc3 extract 'helix' header from property labels and make it the frame header 2025-12-12 15:33:00 -05:00
David Kaufman 07ed72fe16 rename HelixIdealDiameter to HelixMaxDiameter and update documentation 2025-12-12 15:33:00 -05:00
tarman3 ef0782c518 CAM: ToggleOperation - Allow for Job and Operations group 2025-12-12 21:07:53 +02:00
tarman3 fba419f6cb CAM: OperationCopy improve 2025-12-12 21:07:39 +02:00
sliptonic 442a36bea6 Merge pull request #25285 from tarman3/profile_restore
CAM: Profile - clean areaOpOnDocumentRestored()
2025-12-12 12:59:55 -06:00
sliptonic 293038762c Merge pull request #25960 from Connor9220/FixBoundaryDressup
CAM: Refactor stock used as boundary to be distinct from regular stock
2025-12-12 12:39:16 -06:00
tarman3 8fcecc97cb CAM: PathCommands - Remove unused import QtCore 2025-12-12 20:32:23 +02:00
sliptonic 7a0b613561 Merge pull request #25218 from tarman3/geom_tol
CAM: Path.Geom.cmdsForEdge() - add tolerance
2025-12-12 12:29:04 -06:00
sliptonic 0135bba534 Merge pull request #24297 from tarman3/simplecopy
CAM: SimpleCopy - Allow multiple selection
2025-12-12 12:23:35 -06:00
sliptonic b5185a0a22 Merge pull request #25827 from tarman3/pathcommands_looperror
CAM: PathCommands - Remove pop message about loop error
2025-12-12 12:19:38 -06:00
sliptonic 72bc4ef1bd Merge pull request #25938 from Connor9220/AddAnnotationsToCommand
CAM: Add annotations support to Command constructor and Python bindings
2025-12-12 12:17:09 -06:00
sliptonic c495890491 Merge pull request #25786 from Connor9220/FixLinuxCNCPostprocesor
CAM: Add rigid Tapping back to legacy LinuxCNC postprocessor
2025-12-12 11:44:36 -06:00
sliptonic 45386cdcb7 Merge pull request #25783 from Connor9220/AddUnitsPerToolbit
CAM: Add Units (Metric/Imperial) property to ToolBit
2025-12-12 10:46:42 -06:00
sliptonic 96d1084484 Merge pull request #25850 from petterreinholdtsen/cam-fanuc-post-fixes
CAM: Get Fanuc post processor working and implement several improvements
2025-12-12 10:41:51 -06:00
sliptonic 78102d294d Merge pull request #26008 from tarman3/editor_setText
CAM: CodeEditor - stub for setText()
2025-12-12 10:34:17 -06:00
luzpaz 5c0ff4bd8a Fix typos
Fixes various documentation/source-comment typos
2025-12-12 13:59:38 +01:00
PaddleStroke 893a9d19b6 Core: move getPlacementProperty to be more accessible (#26088)
* Core: move getPlacementProperty to be more accessible

* Update DocumentObject.h

* Update DocumentObject.cpp

* Update ViewProviderDragger.h

* Update ViewProviderDragger.cpp

* Update DocumentObject.h

* Update DocumentObject.cpp

* Update ViewProviderLink.cpp

* Update DocumentObject.h

* Update DocumentObject.cpp

* Update DocumentObject.h
2025-12-12 11:59:03 +00:00
Ajinkya Dahale 0800791a0f Sketcher: Only transfer angle to relevant segment on trim etc. 2025-12-12 11:23:00 +05:30
Ajinkya Dahale 78e5729520 Sketcher: Handle angle constraint on sketchobject changes
Primarily trim, but also expected to affect split, extend etc.
2025-12-12 09:17:05 +05:30
PaddleStroke 9625a71d8d Assembly: joint task: fix delete impossible of non-valid refs 2025-12-11 19:04:27 -06:00
Chris Hennes bb25a4efbc Merge pull request #26089 from Roy-043/Draft-fix-lag-when-snapping-to-face-intersections
Draft: fix lag when snapping to face intersections
2025-12-11 19:01:22 -06:00
Alfredo Monclus f92c8e126c PardDesign: fix hole task thread combos not translating 2025-12-11 18:56:10 -06:00
Kacper Donat c10f5d74d3 PartDesign: Recompute preview after forced recompute
This fixes some cases where Preview was stale and not recomputed after
changes done via code.
2025-12-11 18:55:10 -06:00
Roy-043 4b379c8e51 Draft: fix lag when snapping to face intersections
Fixes #25924.

The `snapToIntersection` function has been changed to an if-elif structure, and in case of face-edge intersection snap, only two sublements are checked. This ensures a reasonable speed, even if objects have many edges and faces. The change does mean you have to move the mouse over the correct face for it to be processed. But since face-edge intersection snap is new anyway, this is acceptable I think.
2025-12-11 17:32:44 +01:00
Roy-043 e1d77cc771 Remove maxSnapFaces parameter from params.py
Removed 'maxSnapFaces' parameter from settings.
2025-12-11 17:22:30 +01:00
timpieces de2f8a58a3 Add proper tooltips for Material properties #24434 (#25509) 2025-12-11 14:56:26 +00:00
tarman3 b567525768 CAM: RampEntry Dressup - Remove X0Y0 from beginning 2025-12-11 08:22:35 +02:00
Petter Reinholdtsen 9c78ced00c CAM: Made Fanuc post processor compatible with FreeCAD 1.1.
Use setPlainText() if available, otherwise use setText().
Workaround for a regression from #23862.
2025-12-11 00:57:21 +01:00
Petter Reinholdtsen 8386f1394e CAM: Adjusted Fanuc post processor to move Z to tool change position before M6
A "G28 G91 Z0" is needed according to testing and page 195 (6-1-2 Procedure for ATC operation) in
<URL: https://www.milco.bg/source/Technical%20Service/Documentation%20Dahlih/MCV%20510_1250B%20Operation%20and%20maintenance%20manual%20V2_2.pdf >
to get the spindle into the correct position for a tool change.
2025-12-11 00:57:21 +01:00
Petter Reinholdtsen e6c95dbb91 CAM: Added test of Fanuc post processor
Used TestMach3Mach4LegacyPost.py as the starting point with input from
other test scripts too.

The test demonstrate a fix for #25723, as the Fanuc post processor has not been not updated to the latest changes in
the Path module.

This is related to #24676, where thread tapping was added to LinuxCNC, but the equivalent code in the Fanuc
postprocessor were not adjusted to cope, and #25677 where it was observed that the Fanuc postprocessor was
broken in versions 0.20 and 1.0.

Added MockTool class to provide ShapeName to fanuc_post.py, used to
convert drill cycles to threading cycles if the tool has shapeid "tap".
2025-12-11 00:57:21 +01:00
Petter Reinholdtsen 38c3eebd7a CAM: Made Fanuc post processor compatible with FreeCAD 1.0.
Several methods introduced 2025-05-04 are preferred, but the methods
available in version 1.0 are used as fallback sources
for active status and coolent enabled.
2025-12-11 00:57:21 +01:00
Petter Reinholdtsen 34a5301862 CAM: Switched Fanuc post processor to end program with M30, not M2.
The difference according to the documentation is that M30 will rewind
the paper tape while M2 will not.  The effect on a CNC from 1994 is
that M30 turn on the indicator light marking that the program has
completed, while M2 do not, and the light is wanted to know when
the machine is done.
2025-12-11 00:57:21 +01:00
Petter Reinholdtsen 8b500ca9a3 CAM: Adjusted Fanuc post processor to use M05 consistently everywhere. 2025-12-11 00:57:21 +01:00
Petter Reinholdtsen 4c18ac6c54 CAM: Provide correct and more relevant header from Fanuc post processor
Fanuc only understand upper case letters, no point in providing the
file name in lower case letters.  The provided file name is always "-",
so drop it completely. The first comment is presented in the Fanuc user
interface, it should get more relevant content.

Dropped useless semicolon.
2025-12-11 00:57:21 +01:00
Petter Reinholdtsen e4862572ae CAM: Avoid Z overtravel error on Fanuc tool changes
Enabling tool height compensation will cause the axis to move up
the length of the tool, which will cause a Z overtravel error when
the tool change take place close to the top of the machine.  To
counter this move, ask the machine to move its commanded position
down the length of the tool height, which in effect causes no upward
movement after the tool change.  The #4120 variable contain the
current tool number, and #2000 - #20XX contain the tool heights.
2025-12-11 00:57:21 +01:00
Petter Reinholdtsen bcb569977d CAM: Avoid adding trailing space to all M6 lines.
The Fanuc post processor add a trailing space to all M6 lines.
This make it problematic to write test for the generated output,
when compiled with the automatic policy enforcer on github
removing trialing space from the expected output.  Avoid the
problem by removing the trailing space from the generated
output.
2025-12-11 00:57:21 +01:00
Petter Reinholdtsen 3c5f39c0ca CAM: Corrected Fanuc post processor M3 handling
The thread tapping implementation in the Fanuc post processor change
behaviour of M3, G81 and G82 when the tool ShapeID matches "tap".
but the code not not expect that the parse() method will be
called with two different classes as arguments.

Rewrite the M3 handling to handle ToolController arguments
instead of crashing with an AttributeError.

Issues:

Fixes #14016
Fixes #25723
2025-12-11 00:57:21 +01:00
Petter Reinholdtsen 06fe4b37ba CAM: Switch Fanuc post processor default for M6T0 to disable by default. 2025-12-11 00:57:21 +01:00
Petter Reinholdtsen 87185c8135 CAM: Made empty spindle at the end optional in Fanuc CAM post processing script
Some Fanuc machines do not understand the 'M6 T0' instructions in the
preamble.  Move it out of the preamble and controlled by a new
command line argument --no-end-spindle-empty for the machines
where running to cause a "Tool Number Alarm" and the program to crash
as tool zero is not a valid tool.

Fixes: #25677
2025-12-11 00:57:21 +01:00
Petter Reinholdtsen 0cdf9abc4b CAM: Adjusted Fanuc post processing script to always start with a percent
The percent signal to the machine that a program follows, and is not
part of the header but a required part when uploading programs into
the machine.
2025-12-11 00:57:21 +01:00
Petter Reinholdtsen ef794c31bd CAM: Adjusted Fanuc post processing script to not inherit behaviour between calls
Reset line number when using --line-numbers.  Restore all default values when a
command line argument is not used.

This helps the test scripts ensure that the arguments passed during one test is the only
one taking effect during this test.
2025-12-11 00:57:21 +01:00
Petter Reinholdtsen 533e957f80 CAM: Print "Show editor" status boolean as string, not integer
This get rid of a Python style warning and make the output easier
to understand.
2025-12-11 00:57:20 +01:00
PaddleStroke 7a8135d863 Core: Add getPlacementOf replacing previous getGlobalPlacement logic. (#26059)
* Core: Add getPlacementOf replacing previous getGlobalPlacement logic.

* Update src/App/DocumentObject.cpp

Co-authored-by: Kacper Donat <kadet1090@gmail.com>

* Update DocumentObject.cpp

* Fix error when called from python with targetObj == None

---------

Co-authored-by: Kacper Donat <kadet1090@gmail.com>
2025-12-10 22:47:20 +01:00
Billy Huddleston 5085a286bd CAM: Add Units (Metric/Imperial) property to ToolBit
This PR allows each Toolbit to have its own Units property (Metric/Imperial) for better unit management.

Short Summary:
- Adds a Units property (Metric/Imperial) to ToolBit objects for better unit management.
- Ensures ToolBit schema is set and restored properly in the editor and utilities.
- Updates formatting and property handling to respect the selected units.
- Improves the ToolBit editor widget to refresh and sync schema/UI when units change.
- Uses FreeCAD.Units.setSchema and getSchema to switch between unit schemas.

NOTE: Toolbit dimensions are read from JSON in their native units  (as specified by the Units property),
converted to metric for all internal calculations, and displayed in the UI using the
toolbit's selected units. This ensures both accurate internal computation and user-friendly
display, while storing the correct units in the JSON. This can cause some rounding differences
when switching units. Example: 2 mm becomes 0.0787 inches. If you save that as imperial and then
switch back to metric, it will show 1.9999 mm

src/Mod/CAM/Path/Tool/toolbit/models/base.py:
- Add Units property to ToolBit and ensure it's set and synced with toolbit shape parameters.
- Update property creation and value formatting to use Units.

src/Mod/CAM/Path/Tool/toolbit/ui/editor.py:
- Use setToolBitSchema to set schema based on toolbit units.
- Add logic to refresh property editor widget when units change.
- Restore original schema on close.
- Improve docstrings and signal handling.

src/Mod/CAM/Path/Tool/toolbit/util.py:
- Add setToolBitSchema function for robust schema switching.
- Update format_value to use schema and units.
- Add docstrings and clarify formatting logic.

src/Mod/CAM/Path/Tool/library/ui/browser.py:
- Restore original schema after editing toolbit.

src/Mod/CAM/Path/Tool/library/ui/editor.py:
- Ensure correct schema is set for new toolbits.
2025-12-10 14:57:33 -05:00
Kacper Donat c12ca7b3ba Stylesheets: Fix toolbar button size change 2025-12-10 20:15:34 +01:00
Yash Suthar aed9b770f3 Link: Fixed Scale property behaviour when the object is moved
Signed-off-by: Yash Suthar <yashsuthar983@gmail.com>
2025-12-10 20:13:56 +01:00
Chris Hennes 67948d60a2 PD: Add deprecation warning if Midplane is set 2025-12-10 12:42:13 +01:00
sliptonic 5ad6a1ba58 Merge pull request #26038 from jffmichi/cam_viewprovider_accidental_change
CAM: revert accidental icon name change from #25440
2025-12-09 07:53:17 -06:00
jffmichi 8058f824e2 CAM: revert accidental icon name change from #25440 2025-12-09 05:53:05 +01:00
freecad-gh-actions-translation-bot f7483a08b4 Update translations from Crowdin 2025-12-08 22:31:48 -06:00
Max Wilfinger ff36528155 Update stale issue and PR settings in workflow 2025-12-08 11:34:50 -06:00
PaddleStroke 3608c9f8c4 Part: TopoShape make getElementTypeAndIndex more robust (#25913)
* Part: TopoShape make getElementTypeAndIndex more robust
* Part: Add unit tests for new regex

---------

Co-authored-by: Chris Hennes <chennes@gmail.com>
2025-12-08 11:24:13 -06:00
Chris Hennes 6f511f7911 Merge pull request #25903 from WandererFan/CosVertexCrashInScript
TechDraw: Prevent crash on adding cosmetic feature before geometry created
2025-12-08 11:22:21 -06:00
Syres916 9375f579f0 Merge pull request #25809 from Syres916/HotFix_For_Win_and_Wayland_For_First_Run
[Gui] Hotfix for correcting main window position on first run and Safe Mode on Windows and Wayland
2025-12-08 11:18:58 -06:00
dependabot[bot] 7a493002ac Bump peter-evans/create-pull-request from 7.0.9 to 7.0.11
Bumps [peter-evans/create-pull-request](https://github.com/peter-evans/create-pull-request) from 7.0.9 to 7.0.11.
- [Release notes](https://github.com/peter-evans/create-pull-request/releases)
- [Commits](https://github.com/peter-evans/create-pull-request/compare/84ae59a2cdc2258d6fa0732dd66352dddae2a412...22a9089034f40e5a961c8808d113e2c98fb63676)

---
updated-dependencies:
- dependency-name: peter-evans/create-pull-request
  dependency-version: 7.0.11
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-12-08 09:25:28 -06:00
tarman3 76d939c21f CAM: CodeEditor - stub for setText() 2025-12-07 20:23:14 +02:00
tetektoza 915b6f9901 Gui: Fix preferences search popup positioning on Wayland (#25675)
* Gui: Fix preferences search popup positioning on Wayland

Change window flag from `Qt::Tool` to `Qt::ToolTip` to fix popup
appearing in center of screen and closing immediately on Wayland desktop
envs. `Qt::ToolTip` uses xdg_popup protocol which provides proper
positioning relative to parent window on Wayland.

* Gui: Initialize ok check flag to default in prefs

* Gui: Use ranged for loop where possible in prefs

* Gui: Remove unused variable in preferences controller

* Gui: Use const where possible in prefs search dialog

* Gui: Use static where possible in search prefs dialog

* Gui: Use braced initializer list when returning type in search prefs

* Gui: Use auto in search prefs dialog where possible

* Gui: Do not use else if after return in search prefs dialog

* [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>
2025-12-07 11:43:09 +01:00
wandererfan b1cbcbd238 [TD]fix CI fail on Win 2025-12-05 18:33:16 -05:00
wandererfan 3f10abe11b [TD]fix CosmeticVertex fail in script 2025-12-05 18:33:16 -05:00
Chris Hennes 6ec9870d54 Merge pull request #25853 from 3x380V/reimplement_24749
TechDraw: Fix dimension formatter
2025-12-05 16:07:14 -06:00
Frank David Martínez M a70ec178b8 Gui: Fix 25974 freecad.gui alias regression (#25975) 2025-12-05 19:03:40 +00:00
Adrian Insaurralde Avalos fbb65a34fe Plot: protect matplotlib.pyplot import form PyQt6 too and remove lingering debug print 2025-12-05 10:15:02 -06:00
PaddleStroke a49d106807 Sketcher: Fix errors message when selecting circle seam point. (#25953) 2025-12-05 07:17:30 +00:00
Sebastian 945ba15e18 Match the string that gets sent to setCommand (#25964)
* Match the string that gets sent to setCommand

Correction of a not matching string that gets sent to setCommand. This results in a not translated menu item in the Sketcher menu.

* [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>
2025-12-05 06:38:17 +01:00
PaddleStroke 67234e98b7 Sketcher: Offset: Fix failure if 2+ closed wires with different orientations (#25941) 2025-12-04 23:06:01 -06:00
marioalexis 9d5f6c82be Fem: Fix undefined variable 2025-12-04 22:51:33 -06:00
Billy Huddleston 8e2dc8cd19 CAM: Refactor stock used as boundary to be distinct from regular stock
This commit makes boundary stock objects distinct from regular stock by
setting a boundary flag and label, and prevents editing of boundary
objects in the job view provider.

src/Mod/CAM/Path/Dressup/Boundary.py:
- Add promoteStockToBoundary method, set boundary properties, handle
missing stock/shape

src/Mod/CAM/Path/Main/Gui/Job.py:
- Block editing for objects flagged as boundary stock
2025-12-04 12:43:43 -05:00
Frank David Martínez M d7a7416398 [Core] FreeCADInit and FreeCADGuiInit refactoring (#23413) 2025-12-04 11:10:53 -06:00
Adrian Insaurralde Avalos af48da0dbf WindowsInstaller: more robust automatic version info from freecadcmd
otherwise it broke if freecad had other unrelated output
2025-12-03 15:24:55 -06:00
Billy Huddleston 047cd38c24 CAM: Add annotations support to Command constructor and Python bindings
This commit introduces support for passing an 'annotations' dictionary
to the Command class constructor and its Python bindings. The annotations
dictionary can contain string or numeric values for each key, allowing for
richer metadata on CAM commands. Each annotation must be provided as a
key-value pair within a dictionary.

Examples:

cmd = Command("G1", {"X": 10.0, "Y": 5.0}, {"note": "Rapid move"})

cmd = Command("G2", {"X": 20.0, "Y": 15.0}, {"priority": 1})

cmd = Command("G3", {"X": 30.0, "Y": 25.0}, {"note": "Arc move", "speed": 1500})

cmd = Command("G0", {"X": 0.0, "Y": 0.0}, {})

cmd = Command("G0", {"X": 0.0, "Y": 0.0})

cmd = Command("G1", {"X": 10.0, "Y": 5.0}, annotations={"note": "Rapid move"})

src/Mod/CAM/App/Command.cpp:
- Added new Command constructor accepting annotations

src/Mod/CAM/App/Command.h:
- Declared new Command constructor with annotations parameter

src/Mod/CAM/App/Command.pyi:
- Updated docstring to describe annotations argument

src/Mod/CAM/App/CommandPyImp.cpp:
- Extended Python init to parse and set annotations dictionary
2025-12-03 15:44:18 -05:00
Chris Hennes ee394d2e58 Merge pull request #25920 from PaddleStroke/patch-840798
Sketcher: Fix warning when using dimension tool
2025-12-03 13:09:40 -06:00
PaddleStroke 5f70c4390d Part: revert changes to ViewProviderExt::getDetails (#25912) 2025-12-03 12:12:27 -06:00
sliptonic 2b22873d66 Merge pull request #25908 from Connor9220/FixJobAssignment
CAM: Fix job assignment and model/stock initialization in ObjectOp
2025-12-03 11:57:49 -06:00
Ladislav Michl 90086d3e31 Revert "[Base]retrieve unit text"
This reverts both pointless and broken commit c9fffa6789.
2025-12-03 17:43:53 +01:00
Ladislav Michl 3252aaf618 TechDraw: Refactor use of Unit Schema values
Quantity's getUserString already returns both factor and unitText.
2025-12-03 17:43:53 +01:00
Ladislav Michl a509bc2ee9 TechDraw: Fix MultiValueSchema formatting
Multi Value schemas cannot be forced to use Format::FORMATTED.
2025-12-03 17:17:58 +01:00
PaddleStroke 0c34c93fe4 Sketcher: dimension tool, use VPSketch version of addSelection 2025-12-03 15:30:44 +01:00
PaddleStroke 1784be046f Sketcher: Make VPSketch::addSelection public 2025-12-03 15:29:01 +01:00
Billy Huddleston ab817f8dc5 CAM: Fix job assignment and model/stock initialization in ObjectOp
This PR fixes a bug introduced with PR #25800
It updates the ObjectOp class to correctly assign the job, model,
and stock properties from the parentJob object. Previously, only
PathUtils.addToJob was called, which did not set these attributes directly.

This change ensures that when creating a new operation, the job, model,
and stock fields are properly initialized from the parent job. This
fixes issues where operations did not inherit the correct job context,
leading to missing or incorrect references to the model and stock, and
potential errors in downstream processing.
2025-12-03 00:23:23 -05:00
Roy-043 4f4db09572 Part: make Part_EditAttachment nesting aware (#25887) 2025-12-02 22:44:55 -06:00
PaddleStroke 7c2dac1278 GUI: Fix broken build - splitbutton (#25892) 2025-12-02 20:24:57 -06:00
dependabot[bot] 280382ad3e Bump step-security/harden-runner from 2.13.2 to 2.13.3
Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.13.2 to 2.13.3.
- [Release notes](https://github.com/step-security/harden-runner/releases)
- [Commits](https://github.com/step-security/harden-runner/compare/95d9a5deda9de15063e7595e9719c11c38c90ae2...df199fb7be9f65074067a9eb93f12bb4c5547cf2)

---
updated-dependencies:
- dependency-name: step-security/harden-runner
  dependency-version: 2.13.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-12-02 12:24:11 -06:00
sliptonic 20c2eee9db CAM: Suppress rendering of first rapids (#25440) 2025-12-02 12:20:07 -06:00
dependabot[bot] a0c9b2ecb9 Bump github/issue-metrics from 3.25.3 to 3.25.4
Bumps [github/issue-metrics](https://github.com/github/issue-metrics) from 3.25.3 to 3.25.4.
- [Release notes](https://github.com/github/issue-metrics/releases)
- [Commits](https://github.com/github/issue-metrics/compare/78b1d469a1b1c94945b15bd71dedcb1928667f49...55bb0b704982057a101ab7515fb72b2293927c8a)

---
updated-dependencies:
- dependency-name: github/issue-metrics
  dependency-version: 3.25.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-12-02 19:11:16 +01:00
PaddleStroke ac0685b841 Assembly CommandInsertNewPart : Make sure assembly file is saved (#25730)
Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>
2025-12-02 04:30:20 +00:00
PaddleStroke 6ddb0165ff Sketcher: fix new external always construction (#25733) 2025-12-01 21:49:24 -06:00
Frank Martinez c057d0293a Build: Fix some trivial warnings 2025-12-01 20:57:09 -06:00
Billy Huddleston b5d97057be CAM: Introduce unified ToolBit parameter migration logic for Bullnose tools
- Added new migration system to handle legacy parameter conversion for ToolBit assets and objects.
- Implemented ParameterAccessor abstraction for consistent access to dicts and FreeCAD objects.
- Centralized migration logic for CornerRadius from TorusRadius or FlatRadius/Diameter, restricted to Bullnose shape-type.
- Updated asset and object initialization to use migration logic and filter Bullnose parameters.

src/Mod/CAM/Path/Tool/camassets.py:
- Integrate new migration logic for ToolBit assets using ParameterAccessor and migrate_parameters.
- Ensure shape-type is set before parameter migration; only write changes if migration occurred.

src/Mod/CAM/Path/Tool/toolbit/migration.py:
- Add ParameterAccessor class and migrate_parameters function for unified migration.
- Handle legacy parameter conversion for Bullnose tools.

src/Mod/CAM/Path/Tool/toolbit/models/base.py:
- Apply migration logic to ToolBit objects on restore.
- Filter Bullnose parameters to remove FlatRadius after migration.

src/Mod/CAM/Path/Tool/shape/models/bullnose.py:
- Add filter_parameters method to remove FlatRadius for Bullnose.

src/Mod/CAM/Path/Op/SurfaceSupport.py:
- Derive FlatRadius from CornerRadius and Diameter if both are present.

src/Mod/CAM/Path/Op/Surface.py:
- Remove obsolete setOclCutter method.
2025-12-01 11:30:00 -06:00
Chris Hennes 1b886ef961 Revert "GUI: fix "select all instances" (#25503)"
This reverts commit 6b60867368.
2025-12-01 18:24:25 +01:00
Chris Hennes f366b0e2a7 Utils: Don't save location of Python executable 2025-12-01 17:03:46 +00:00
Roy-043 4eb110e861 Draft: fix X-axis reference for Draft_Arc_3Points 2025-12-01 17:01:31 +00:00
PaddleStroke b603630d1f Assembly: Fix selection during joint edition (#25687) 2025-12-01 17:01:19 +00:00
Garfieldcmix 3aedb58e4b Fix Export/Save Mesh incorrect error message 2025-12-01 11:00:40 -06:00
sliptonic db65e44bca CAM: fixes bug with op creation/cancelation (#25800) 2025-12-01 10:59:49 -06:00
Syres916 cb9c0ccd7f [TechDraw] QCheckBox fix compiling warning of stateChanged deprecation 2025-12-01 10:59:25 -06:00
Roy-043 5e90dc86fb BIM: BIM_Material: only assign material object to component (#25823)
* Add MoveWithHost check for material assignment

* [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>
2025-12-01 16:59:13 +00:00
Roy-043 41c0621abb BIM: add parameter for BIM_Sketch view props (#25778)
* Add BIM parameters to param_dict

Add BIM parameters to param_dict for future use.

* BIM: add parameter for BIMSketch view props
2025-12-01 16:58:43 +00:00
Roy-043 5155906848 BIM: fix Arch_Reference update on doc restored (#25777)
* BIM: fix Arch_Reference update on doc restored

Fixes: #24943

* [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>
2025-12-01 16:58:01 +00:00
tetektoza 5f4fe75f5f Sketcher: Use constraint index instead of geoId as key in expr storage
`SketcherTransformationExpressionHelper` was using `geoId` as the map
key for storing expressions during geometry transformations. This is
incorrect since single geometry may have multiple constraints with
different expressions.

So, using `geoId` as the key causes `std::map` overwrites, resulting in
only the last expression being preserved per geometry.

So this patch changes key to be a constraint index, and adds
`ConstraintExpressionInfo` struct to store both expression and `geoId`.

Co-authored-by: PaddleStroke <pierrelouis.boyer@gmail.com>
2025-12-01 10:57:40 -06:00
Billy Huddleston 708717cee2 CAM: Turn off debugging in CAM Preferences
Debugging was left on by mistake. Also 'Setting asset path' log message was at info level. Changed to debug level.
2025-12-01 10:53:02 -06:00
Chris Hennes cbd9414684 Merge pull request #25713 from kadet1090/split-button
Gui: Use SplitButton for config migration modal
2025-12-01 10:52:19 -06:00
Roy-043 6a65b45242 Convert asset path to string in filePath function 2025-12-01 10:51:16 -06:00
marbocub 8ea5075385 Sketcher: Fix error when first constraint is DistanceX/DistanceY to vertex (#25813) 2025-12-01 10:50:31 -06:00
Syres916 15c99ecdb2 [TechDraw] Fixes for TaskFillTemplateFields finding Draft/Arch/Image views and keeping message boxes and dialogs on top (#25342)
* [TechDraw] fix dialog to be ontop, clear the keyLst and save mouse movement between messagebox and dialog

* [TechDraw] change from setWindowFlags to setWindowFlag

* [TechDraw] handle BIM and Draft as first available views...

.... also increase the possible scale values such as 5 : 2 or 7 : 3

* [TechDraw] fix 1:1 scale regression

* [TechDraw] remove unnecessary line of code

* TD: Simplify code

Address comments from review.

Co-authored-by: WandererFan <wandererfan@gmail.com>

* [TechDraw] enable use of Fraction for scale...

... conversion

---------

Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>
Co-authored-by: WandererFan <wandererfan@gmail.com>
2025-12-01 10:45:02 -06:00
Syres916 2be7bbf141 [Gui] Fix AxisLetterColor on opening Preferences and correct LightSources parameter group
Also remove workaround as stated in the comments just before 1.1.0 Release.
2025-12-01 17:34:44 +01:00
Roy-043 b865c4625d BIM: Fix duplicate vertices in Wavefront OBJ export
Fixes: #13151.

The vertices derived from a face's outerwire could contain duplicates.

Fixed by switching to:
`f.OuterWire.OrderedVertexes`
2025-12-01 16:28:14 +00:00
PaddleStroke 6d48c51f4d Part: Fix addSelection failing for links to body. (#25702) 2025-12-01 09:34:08 -06:00
tarman3 eb703bfde7 CAM: Slot - Remove .0 2025-12-01 09:32:01 +02:00
PaddleStroke b249b9daeb Core: Close partially opened document when doc is closed. (#25659) 2025-11-30 23:33:43 -06:00
Captain a371231aea PartDesign: fix symmetric mode of draggers in revolution/groove (#25656) 2025-11-30 23:03:31 -06:00
sliptonic 98a2cb52c3 Merge pull request #25273 from Thom-de-Jong/main
CAM: Exporting G-code can be canceled from the editor dialog
2025-11-30 14:04:22 -06:00
tarman3 b6ae98fa0a CAM: PathCommands - Remove pop message about loop error 2025-11-30 20:08:12 +02:00
tarman3 0e85c53cfe CAM: Path.Geom.cmdsForEdge() - add tolerance 2025-11-30 18:19:17 +02:00
sliptonic 46f9cb0ac5 Merge pull request #25253 from tarman3/geom_usehelixforbspline
CAM: Path.Geom.cmdsForEdge() - remove useless 'useHelixForBSpline'
2025-11-30 09:59:03 -06:00
Thom de Jong bbb3bdd839 Merge remote-tracking branch 'upstream/HEAD' 2025-11-30 12:43:31 +01:00
Frank Martinez a8c7968c92 CAM: Fix pyi signature to match c++ 2025-11-30 00:56:44 -06:00
Chris Hennes dfb9baf678 Merge pull request #24262 from mnesarco/pyi-fixes-1 2025-11-29 20:23:37 -06:00
Frank Martinez be7c10aea4 [bindings] Added generic twin pointer accessor 2025-11-29 20:22:38 -06:00
sliptonic 28b9fa0151 Merge pull request #25553 from tarman3/leadinout_overtravel6
CAM: LeadInOut - Fix regression after #24829
2025-11-29 12:34:37 -06:00
Chris Hennes 6ad6a98881 Merge pull request #25674 from WandererFan/DimensionColorSizeOldDocuments2
TechDraw: fix handling of alpha channel in old documents
2025-11-28 18:04:30 -06:00
Billy Huddleston f3f601105e CAM: Add rigid Tapping back to legacy LinuxCNC postprocessor
This PR adds rigid tapping back to the legacy LinuxCNC postprocessor, which
was removed in commit cd1c29e3f23fde0a90980ffcf3e70406769f2d43 in PR 24771.

The changes include:
- Modifying the linuxcnc_legacy_post.py script to include logic for Rigid tapping
- Updating comments and documentation to reflect the addition of Rigid tapping
2025-11-28 18:30:28 -05:00
sliptonic eb8b2ddad2 [CAM] Reimplemented Mill facing operation (#24367) 2025-11-28 23:26:36 +00:00
tarman3 91fd699f2d CAM: Path.Geom.cmdsForEdge() - remove useless 'useHelixForBSpline' 2025-11-28 20:13:24 +02:00
sliptonic f18842114f Merge pull request #25205 from tarman3/isVertical
CAM: Path.Geom.isVertical() for BSpineSurface (simple face after scale)
2025-11-28 12:08:10 -06:00
sliptonic effe043019 Merge pull request #25635 from tarman3/oputil_1_linter
CAM: OpUtil - Fix linter errors
2025-11-28 12:03:06 -06:00
sliptonic 1ff6d15b64 Merge pull request #25023 from sebastianohl/main
CAM: fixing drill handling, as KinetiNC does not implement G81 etc. correctly
2025-11-28 11:54:08 -06:00
sliptonic c3068b2b66 Merge pull request #25022 from s-ohl-ostfalia-de/main
CAM: adding cooling feature to Kinetic post processor
2025-11-28 11:52:29 -06:00
sliptonic 83fc0385a3 Merge pull request #24807 from tarman3/inspect
CAM: Line numbers in Inspect window
2025-11-28 11:48:24 -06:00
sliptonic e20fd153ed Merge pull request #23862 from tarman3/gcode_editor_dialog
CAM: Show line numbers in export gcode dialog
2025-11-28 11:47:01 -06:00
sliptonic a2dc485c2b Merge pull request #23251 from sliptonic/adr-expand-command-semantics
[CAM] ADR on Path Command annotation semantics
2025-11-28 11:07:26 -06:00
sliptonic 0e1d87852e Merge pull request #25365 from sliptonic/adr-heights
CAM: ADR for normalizing Heights and depths terminology
2025-11-28 11:03:15 -06:00
sliptonic 57ba779ec8 Merge pull request #25732 from sliptonic/adr-material-allowance
CAM: ADR for "Stock to Leave" terminology
2025-11-28 10:50:58 -06:00
PaddleStroke 79f66b75f3 Datums: Prevent 'doesn't contain feature with role' error on load 2025-11-28 12:08:38 +01:00
Kacper Donat 0de9ffc439 Gui: Use SplitButton for config migration modal 2025-11-28 10:15:04 +01:00
Kacper Donat c500408a6d Gui: Add SplitButton widget
This adds SplitButton widget that has one primary action and possibly
more secondary ones accessible via menu.
2025-11-28 10:15:04 +01:00
Chris Hennes 4e74031e06 Build: Fix punctuation in Windows installer (English only) 2025-11-28 06:39:06 +01:00
PaddleStroke 5ae67ee2f9 PartDesign: Polar pattern: Accept negative angles (#25621) 2025-11-27 18:08:01 -06:00
PaddleStroke eaee0f759a TechDraw: DrawViewSpreadsheet do not create cyclic dependency 2025-11-27 18:07:03 -06:00
pre-commit-ci[bot] bdc3781b88 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2025-11-27 16:43:24 +00:00
sliptonic 03e7200f68 revise feed definition 2025-11-27 10:40:13 -06:00
pre-commit-ci[bot] 6cb1e8a9ce [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2025-11-27 16:18:33 +00:00
tarman3 dd3898aa39 CAM: Task panel - Shapes selection from several objects 2025-11-27 12:48:37 +02:00
PaddleStroke da717d4ca0 Assembly: Enable negative distance for rackpinion and screw 2025-11-26 23:53:11 +01:00
PaddleStroke cf40007bd0 Assembly: CommandInsertLink: handle manual deletions (#25651) 2025-11-26 16:22:12 -06:00
Pieter Hijma 63f739b2e4 Gui: Fix refresh on boolean property toggle 2025-11-26 14:42:38 -06:00
Chris Hennes 8604c26ce3 Merge pull request #25580 from kadet1090/fix-boolean-position
PartDesign: Fix boolean positioning
2025-11-26 14:22:59 -06:00
Chris 6b60867368 GUI: fix "select all instances" (#25503) 2025-11-26 14:20:23 -06:00
PaddleStroke 46a847c857 Gui: Do not lose thumbnail when saving partially loaded doc (#25458) 2025-11-26 13:53:11 -06:00
PaddleStroke 8533d23b07 DlgSettingsDocument : fix tooltip 2025-11-26 16:55:18 +01:00
Chris 5382ca4bbb PartDesign: Use c++ exception to prevent crash (#25671)
* part design: fix issue #25639 use c++ exception to prevent crash

* [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>
2025-11-26 15:43:47 +01:00
Eugene Zhukov e270d63e5c Change params variable to uppercase PARAMS (#25663)
Addresses #25565
2025-11-26 13:25:20 +00:00
github-actions 68cb0a3270 Update translations from Crowdin 2025-11-25 21:20:42 -06:00
wandererfan 475d46c3d0 [TD]guard against font size zero 2025-11-25 19:59:59 -05:00
wandererfan e2c5c643d8 [TD]convert transparency to alpha channel 2025-11-25 19:59:53 -05:00
wandererfan 64f2c5388b [TD]add preference re alpha/transparency conversion 2025-11-25 19:59:40 -05:00
Thom de Jong dc4f9c694d Change button text and disable OK when text unchanged 2025-11-25 22:10:32 +01:00
tarman3 06bc4f61e0 CAM: OpUtil - Fix linter errors 2025-11-24 23:21:36 +02:00
Kacper Donat 527b2de560 PartDesign: Bake in geometry transform after boolean
This bakes in transform into geometry after boolean to ensure that
regardless of parameters the result of boolean operation is the same.
2025-11-23 23:10:25 +01:00
Kacper Donat 4cbf10f045 Part: Add bakeInTransform method for TopoShape
This method can be used to bake in transform directly into geometry.
Normally the setTransform or setPlacement methods only store additional
positional data within the shape without changing the actual geometry.
So if we have some geometry placed at 0,0,0 and we want to have few
copies of that shape the goemetry stays intact but additional transform
is stored. This method can be used to alter the gometry and reset the
transform to identity. It helps with model stability, as not every
method correctly handles that additional transform metadata.
2025-11-23 23:10:25 +01:00
Kacper Donat 1555f65075 PartDesign: Simplify FeatureBoolean
This commit removes a ton of dead code from FeatureBoolean. It might
been ported here from the Link branch but it is not used and it is
confusing. The reason for having that code here is also not really
obvious so there is no reason to keep it.
2025-11-23 23:10:25 +01:00
tarman3 94328259ee CAM: Engrave - Remove useless property BaseObject 2025-11-23 21:33:05 +02:00
tarman3 a0876f8060 CAM: LeadInOut - Fix regression after #24829 2025-11-21 23:00:37 +02:00
sliptonic 17d27780ac Fixes #24959 Introduces ADR for "Stock to Leave" 2025-11-21 12:06:23 -06:00
sliptonic b254aa9815 Draft ADR-008 for normalizing Heights and depths terminology 2025-11-21 11:27:37 -06:00
tarman3 6ecc6f780c CAM: Remove dependency Path.Main.Job from Path.Dressup.Utils 2025-11-18 20:46:34 +02:00
pre-commit-ci[bot] 13adb1fb5c [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2025-11-17 19:16:28 +00:00
David Kaufman ad3119306b fix rebase error 2025-11-17 14:06:08 -05:00
David Kaufman f869295d03 update UI to label helix diameter as a percentage, reorganize 2025-11-17 14:06:08 -05:00
David Kaufman a6c7d7c0e7 fix units bug 2025-11-17 14:06:08 -05:00
David Kaufman b19eaff00e fix rebase errors 2025-11-17 14:06:08 -05:00
David Kaufman 09e984d1ce fix github warning 2025-11-17 14:06:08 -05:00
David Kaufman 9e830949a8 [CAM] add helix max stepdown parameter 2025-11-17 14:06:08 -05:00
David Kaufman 80d78efc6b [CAM] update/fix adaptive UI panel and parameter limits 2025-11-17 14:06:08 -05:00
David Kaufman 8aa7117af7 [CAM] initial implementation of automatic helix size selection for adaptive 2025-11-17 14:06:06 -05:00
tarman3 8cb87df0f2 CAM: _migrateRampDressups - fix #25391 2025-11-17 19:56:35 +02:00
tarman3 dc776de547 CAM: Line numbers in Inspect window 2025-11-17 19:55:54 +02:00
tarman3 0e0f948d71 CAM: Show line numbers in export gcode dialog 2025-11-17 19:55:15 +02:00
phaseloop ec3c8cf2bc Merge branch 'main' into v-routing 2025-11-15 17:24:45 +01:00
Phaseloop 33edb3812c Merge branch 'v-routing' of github.com:phaseloop/FreeCAD into v-routing 2025-11-15 17:23:10 +01:00
Phaseloop b7cf22c44f fix broken backtrack edge generation 2025-11-15 17:22:26 +01:00
tarman3 0abfdf237a CAM: Profile - clean areaOpOnDocumentRestored() 2025-11-15 00:07:26 +02:00
tarman3 1ed08a2e43 CAM: Geom - isVertical for BSpineSurface 2025-11-14 23:22:09 +02:00
Thom de Jong cca733810f Merge branch 'main' into main 2025-11-14 17:52:07 +01:00
Max Wilfinger fd45dc1721 Merge branch 'main' into main 2025-11-14 15:16:11 +01:00
tarman3 dc2a3d0d60 CAM: SimpleCopy - Allow for all operations 2025-11-13 23:10:35 +02:00
Thom de Jong dc4f2733e6 Keep old buttons for old post processors 2025-11-13 17:38:31 +01:00
Thom de Jong c15faf9918 Initialise editor_result 2025-11-13 15:25:22 +01:00
Thom de Jong 896443a8ec Merge branch 'FreeCAD:main' into main 2025-11-13 15:22:33 +01:00
Thom de Jong 3e2ace89e9 Merge branch 'FreeCAD:main' into main 2025-11-13 13:23:18 +01:00
Thom de Jong d82f09081a Fix editor_result check 2025-11-13 13:22:52 +01:00
Thom de Jong 5e971d1f91 Merge branch 'FreeCAD:main' into main 2025-11-13 12:44:33 +01:00
Thom de Jong d08659eafc Change G-code editor buttons 2025-11-12 21:11:06 +01:00
pre-commit-ci[bot] 5e0dd60ee5 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2025-11-11 19:34:32 +00:00
Frank Martinez 3561d25c2d [License] Fix pyi license headers. 2025-11-11 13:26:18 -05:00
Frank Martinez d026c6f708 [bindings] remove redundant signatures. batch3 2025-11-11 13:26:18 -05:00
Frank Martinez 93e4858b01 [bindings] remove redundant signatures. batch2 2025-11-11 13:23:10 -05:00
Frank Martinez 7fe379e5ea [bindings] remove redundant signatures. batch1 2025-11-11 13:23:10 -05:00
Frank Martinez 73e67fefd1 [bindings] Automatic export of function signatures with annotations to runtime. (PyMethodDef.ml_doc) 2025-11-11 13:23:10 -05:00
Frank Martinez 1cf57d6e11 [bindings] Format with yapf (precommit will reformat) 2025-11-11 13:23:10 -05:00
Frank Martinez 1b0c0399e9 [bindings] Fix overload order 2025-11-11 13:23:10 -05:00
Frank Martinez 2eedbce181 Rebase on main and fix ViewProviderAssembly.pyi 2025-11-11 13:23:10 -05:00
Frank Martinez dd15887568 [bindings] Fix undefined symbols in pti files 2025-11-11 13:23:10 -05:00
Frank Martinez 2ada443c18 Clean unused imports in .pyi files 2025-11-11 13:23:10 -05:00
Frank Martinez a3232103d5 Fixed docstrings 2025-11-11 13:23:10 -05:00
Frank Martinez 39d15c011e black formatting 2025-11-11 13:23:10 -05:00
Frank Martinez 47e3162dcb [bindings] re-shape some keyword-only signatures 2025-11-11 13:23:09 -05:00
Frank Martinez 6b0b15f687 [bindings] Code cleanup 2025-11-11 13:23:09 -05:00
Frank Martinez 0eae00b9a1 [bindings] Code formatting 2025-11-11 13:23:09 -05:00
Frank Martinez 748004b4e4 [bindings] fix signatures in pyi files 2025-11-11 13:16:26 -05:00
Frank Martinez 8c7f381416 [bindings] Document 2025-11-11 13:08:06 -05:00
Frank Martinez 33f605a125 [bindings] ComplexGeoData 2025-11-11 13:08:05 -05:00
Frank Martinez f1248c2418 [bindings] ApplicationDirectories 2025-11-11 13:08:05 -05:00
pre-commit-ci[bot] 801e9fa6e5 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2025-11-10 23:43:54 +00:00
Phaseloop 440fda29e5 fix job editor crashing 2025-11-11 00:42:14 +01:00
pre-commit-ci[bot] d2fd87cecf [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2025-11-05 11:24:52 +00:00
phaseloop 7684f5a97f Merge remote-tracking branch 'refs/remotes/origin/v-routing' into v-routing 2025-11-05 11:22:29 +00:00
phaseloop 61872a9003 fix linting issues 2025-11-05 11:21:34 +00:00
pre-commit-ci[bot] 48964ed4e1 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2025-11-04 16:21:17 +00:00
PhaseLoop 0cca441fba Improve VCarve edge routing speed 2025-11-04 16:18:44 +00:00
pre-commit-ci[bot] 8d0878e34e [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2025-11-03 14:11:42 +00:00
Sebastian Ohl 15e24bb8cc fixing drill handling, as KinetiNC does not implement G81 etc. correctly 2025-11-03 15:02:14 +01:00
pre-commit-ci[bot] 1514e9b32c [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2025-11-03 13:53:32 +00:00
Sebastian Ohl e4b03f69f0 adding cooling feature to Kinetic post processor 2025-11-03 14:45:12 +01:00
sliptonic ecd8f6e050 revised with github comments 2025-08-20 14:09:00 -05:00
sliptonic 5a7fbb449a expanding Path semantics 2025-08-19 17:39:02 -05:00
Dimitris75 7704426f54 Merge branch 'OCL-Adaptive' of https://github.com/Dimitris75/FreeCAD into OCL-Adaptive 2025-08-19 23:55:46 +03:00
Dimitris75 9c21769410 Update Waterline.py 2025-08-19 23:55:41 +03:00
pre-commit-ci[bot] c458e54e2c [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2025-08-17 01:57:41 +00:00
Dimitris75 b8216284ba Merge branch 'OCL-Adaptive' of https://github.com/Dimitris75/FreeCAD into OCL-Adaptive 2025-08-17 04:51:51 +03:00
Dimitris75 99a5c03ba7 Correct problems found by Github bot
Delete unused lists
2025-08-17 04:39:56 +03:00
pre-commit-ci[bot] ce13cb0174 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2025-08-16 19:03:29 +00:00
Dimitris75 1e9295fe27 round BoundBox
round xmin, xmax, ymin, ymax
2025-08-16 21:25:06 +03:00
Dimitris75 1a9df4eb80 CAM: Waterline OCL Adaptive
Adding OCL Adaptive Algorithm to Waterline Operation
2025-08-16 19:41:01 +03:00
2509 changed files with 309351 additions and 242649 deletions
@@ -7,6 +7,15 @@ body:
value: |
Thanks for taking the time to fill out this problem report! Please [search](https://github.com/FreeCAD/FreeCAD/issues) if a similar issue already exists and check out [how to report issues](https://github.com/FreeCAD/FreeCAD?tab=readme-ov-file#reporting-issues). By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/FreeCAD/FreeCAD/blob/main/CODE_OF_CONDUCT.md).
- type: textarea
id: description
attributes:
label: Problem description
description: Describe the problem and how it impacts user experience, workflow, maintainability or performance. You can attach images or log files by clicking this area to highlight it and then dragging files in. To attach a FCStd file, ZIP it first.
placeholder: Describe your problem briefly.
validations:
required: true
- type: dropdown
id: wb
attributes:
@@ -28,15 +37,6 @@ body:
- TechDraw
- Other (specify in description)
- type: textarea
id: description
attributes:
label: Problem description
description: Describe the problem and how it impacts user experience, workflow, maintainability or performance. You can attach images or log files by clicking this area to highlight it and then dragging files in. To attach a FCStd file, ZIP it first.
placeholder: Describe your problem briefly.
validations:
required: true
- type: textarea
id: steps_to_reproduce
attributes:
@@ -0,0 +1,103 @@
name: Report a Code Quality Issue
description: Report problems related to code structure, maintainability, performance, correctness, or technical debt that do not directly affect end-user behavior.
labels: ["Status: Needs triage", "Status: Needs confirmation", "Type: Code Quality"]
type: "Code Quality"
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to help improve FreeCAD's code quality!
> [!NOTE]
> This form is intended **only for code quality issues**, such as:
> - Architectural or design problems
> - Maintainability or readability issues
> - Performance or scalability concerns
> - Incorrect abstractions, layering violations, or technical debt
>
> If the issue affects user-visible behavior, workflows, or UI, please use the regular **Report Problem** form instead.
Please [search existing issues](https://github.com/FreeCAD/FreeCAD/issues) before submitting.
By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/FreeCAD/FreeCAD/blob/main/CODE_OF_CONDUCT.md).
- type: dropdown
id: wb
attributes:
label: Area / Workbench affected
description: Select the primary area affected by the code quality issue.
options:
- Assembly
- BIM
- CAM
- Core (App, Gui, Base, ...)
- Draft
- FEM
- Material
- Measurement
- Mesh
- Part
- Part Design
- Sketcher
- Spreadsheet
- TechDraw
- Build system / CI
- Documentation
- Other (specify below)
- type: textarea
id: description
attributes:
label: Problem description
description: |
Describe the code quality issue clearly.
Focus on *why* the current implementation is problematic (e.g. maintainability, performance, correctness, extensibility).
Reference files, classes, functions, or modules where applicable.
placeholder: |
Example:
- Class X violates dependency rules by including Y
- Function Z mixes responsibilities and is hard to reason about
- Algorithm has unnecessary complexity or poor performance characteristics
validations:
required: true
- type: textarea
id: impact
attributes:
label: Impact
description: |
Explain the practical impact of this issue.
For example: increased maintenance cost, higher bug risk, performance degradation, difficulty extending functionality, or CI/build issues.
placeholder: Describe how this affects the codebase long-term.
validations:
required: true
- type: textarea
id: proposed_solution
attributes:
label: Suggested improvement (optional)
description: |
If you have ideas on how to address the issue, outline them here.
This can include refactoring suggestions, alternative designs, or references to best practices.
placeholder: Optional — leave empty if unsure.
- type: textarea
id: references
attributes:
label: References / evidence
description: |
Add relevant references such as:
- File paths or code snippets
- Related issues or pull requests
- Benchmarks, logs, or static analysis results
placeholder: Links, snippets, or related issues.
- type: textarea
id: dev_version
attributes:
label: Development version (if relevant)
description: |
If the issue is version-specific or recently introduced, paste the output from the
**About FreeCAD** dialog of a development build.
Otherwise, this can be left empty.
placeholder: Paste About FreeCAD information here.
render: shell
+1 -1
View File
@@ -58,7 +58,7 @@ jobs:
logdir: /tmp/log/
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
uses: step-security/harden-runner@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
with:
egress-policy: audit
+17 -8
View File
@@ -26,14 +26,21 @@
name: FreeCAD master CI
on: [workflow_dispatch, push, pull_request, merge_group]
on:
workflow_dispatch: ~
push:
branches:
- main
- releases/**
pull_request: ~
merge_group: ~
concurrency:
group: FC-CI-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
Prepare:
uses: ./.github/workflows/sub_prepare.yml
with:
@@ -45,20 +52,23 @@ jobs:
with:
artifactBasename: Pixi-${{ github.run_id }}
Ubuntu:
needs: [Prepare]
uses: ./.github/workflows/sub_buildUbuntu.yml
with:
artifactBasename: Ubuntu-${{ github.run_id }}
# Ubuntu:
# needs: [Prepare]
# if: "!startsWith(github.head_ref, 'refs/heads/backport-')"
# uses: ./.github/workflows/sub_buildUbuntu.yml
# with:
# artifactBasename: Ubuntu-${{ github.run_id }}
Windows:
needs: [Prepare]
if: "!startsWith(github.head_ref, 'refs/heads/backport-')"
uses: ./.github/workflows/sub_buildWindows.yml
with:
artifactBasename: Windows-${{ github.run_id }}
Lint:
needs: [Prepare]
if: "!startsWith(github.head_ref, 'refs/heads/backport-')"
uses: ./.github/workflows/sub_lint.yml
with:
artifactBasename: Lint-${{ github.run_id }}
@@ -73,7 +83,6 @@ jobs:
needs: [
Prepare,
Pixi,
Ubuntu,
Windows,
Lint
]
@@ -21,7 +21,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
uses: step-security/harden-runner@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
with:
egress-policy: audit
@@ -30,14 +30,14 @@ jobs:
uses: actions/stale@5f858e3efba33a5ca4407a664cc011ad407f2008 # v10.1.0
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
days-before-issue-stale: 60
days-before-issue-stale: 90
days-before-issue-close: 14
days-before-pr-stale: -1
days-before-pr-close: -1
operations-per-run: 100 # max num of ops per run
operations-per-run: 200 # max num of ops per run
stale-issue-label: 'Status: Stale'
close-issue-label: 'Status: Auto-closing'
exempt-issue-labels: 'Status: Confirmed,Priority: High,Priority: Critical,Blocker,Type: Feature,no-auto-close'
exempt-issue-labels: 'Status: Confirmed,Priority: High,Priority: Critical,Blocker,Type: Feature,no-auto-close,3rd party: OCC'
remove-stale-when-updated: true
ascending: true
stale-issue-message: |
@@ -87,10 +87,10 @@ jobs:
days-before-issue-close: 60
days-before-pr-stale: -1
days-before-pr-close: -1
operations-per-run: 50 # max num of ops per run
operations-per-run: 100 # max num of ops per run
stale-issue-label: 'Status: Stale'
close-issue-label: 'Status: Auto-closing'
exempt-issue-labels: 'Priority: High,Priority: Critical,Blocker,Type: Feature,no-auto-close'
exempt-issue-labels: 'Priority: High,Priority: Critical,Blocker,Type: Feature,no-auto-close,3rd party: OCC'
remove-stale-when-updated: true
ascending: true
stale-issue-message: |
+3 -1
View File
@@ -29,12 +29,14 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
token: ${{ secrets.GH_TOKEN_FOR_CI_RUNNERS }}
- name: Create backport pull requests
uses: korthout/backport-action@d07416681cab29bf2661702f925f020aaa962997 # v3.4.1
with:
# Inputs documented here: https://github.com/korthout/backport-action?tab=readme-ov-file#inputs
github_token: ${{ github.token }}
github_token: ${{ secrets.GH_TOKEN_FOR_CI_RUNNERS }}
github_workspace: ${{ github.workspace }}
# permit PRs with merge commits to be backported
+2 -2
View File
@@ -16,7 +16,7 @@ jobs:
build_tag: ${{ steps.get_tag.outputs.build_tag }}
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
uses: step-security/harden-runner@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
with:
egress-policy: audit
@@ -79,7 +79,7 @@ jobs:
environment: weekly-build
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
uses: step-security/harden-runner@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
with:
egress-policy: audit
+1 -1
View File
@@ -64,7 +64,7 @@ jobs:
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
uses: step-security/harden-runner@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
with:
egress-policy: audit
+1 -1
View File
@@ -68,7 +68,7 @@ jobs:
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
uses: step-security/harden-runner@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
with:
egress-policy: audit
+1 -1
View File
@@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
uses: step-security/harden-runner@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
with:
egress-policy: audit
@@ -25,7 +25,7 @@ jobs:
arch: "linux_gcc_64"
- name: Setup Python & dependencies
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548
with:
python-version: "3.13"
- name: Install Python packages
@@ -57,7 +57,7 @@ jobs:
git push origin update-crowdin-translations --force
- name: Create Pull Request
uses: peter-evans/create-pull-request@84ae59a2cdc2258d6fa0732dd66352dddae2a412
uses: peter-evans/create-pull-request@22a9089034f40e5a961c8808d113e2c98fb63676
with:
branch: update-crowdin-translations
title: "Update translations from Crowdin"
+2 -2
View File
@@ -17,7 +17,7 @@ jobs:
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
uses: step-security/harden-runner@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
with:
egress-policy: audit
@@ -35,7 +35,7 @@ jobs:
echo "last_month=$first_day..$last_day" >> "$GITHUB_ENV"
- name: Run issue-metrics tool
uses: github/issue-metrics@78b1d469a1b1c94945b15bd71dedcb1928667f49 # v3.25.3
uses: github/issue-metrics@67526e7bd8100b870f10b1c120780a8375777b43 # v3.25.5
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SEARCH_QUERY: 'repo:FreeCAD/FreeCAD is:issue created:${{ env.last_month }}'
+1 -1
View File
@@ -21,7 +21,7 @@ jobs:
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
uses: step-security/harden-runner@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
with:
egress-policy: audit
@@ -25,7 +25,7 @@ jobs:
arch: "linux_gcc_64"
- name: Setup Python & dependencies
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548
with:
python-version: "3.13"
- name: Install Python packages
+1 -1
View File
@@ -36,7 +36,7 @@ jobs:
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
uses: step-security/harden-runner@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
with:
egress-policy: audit
+1 -1
View File
@@ -75,7 +75,7 @@ jobs:
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
uses: step-security/harden-runner@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
with:
egress-policy: audit
+1 -1
View File
@@ -77,7 +77,7 @@ jobs:
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
uses: step-security/harden-runner@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
with:
egress-policy: audit
+1 -1
View File
@@ -66,7 +66,7 @@ jobs:
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
uses: step-security/harden-runner@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
with:
egress-policy: audit
+1 -1
View File
@@ -198,7 +198,7 @@ jobs:
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
uses: step-security/harden-runner@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
with:
egress-policy: audit
+1 -1
View File
@@ -81,7 +81,7 @@ jobs:
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
uses: step-security/harden-runner@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
with:
egress-policy: audit
+1 -1
View File
@@ -54,7 +54,7 @@ jobs:
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
uses: step-security/harden-runner@df199fb7be9f65074067a9eb93f12bb4c5547cf2 # v2.13.3
with:
egress-policy: audit
+2 -1
View File
@@ -1,6 +1,7 @@
> [!IMPORTANT]
> Bleeding edge FreeCAD development builds for testing bugfixes, regressions, and recently implemented features. Do not use in a production environment.
**Changes since last weekly:** <!--DIFF_LINK-->
### How-to use
@@ -8,7 +9,7 @@
2. Unpack the bundle to any folder on your system
3. Launch the application
- **Windows**
Run `\bin\FreeCAD.exe` in the extracted directory
Run `\FreeCAD.exe` in the extracted directory
- **macOS**
Launch `/FreeCAD.app` in the extracted directory
- **Linux**
+140
View File
@@ -0,0 +1,140 @@
name: Weekly compare link to release notes
on:
release:
types: [published] # run automatically when a (pre-)release is published
workflow_dispatch: # allow manual runs too
inputs:
current_tag:
description: "Weekly tag (e.g., weekly-2026.01.07). Leave empty to auto-detect latest weekly pre-release."
required: false
dry_run:
description: "Only compute; do not update the release body."
required: false
type: boolean
default: false
permissions:
contents: write # required to PATCH the release body
jobs:
update-notes:
runs-on: ubuntu-latest
steps:
- name: Inject compare link into weekly release notes
uses: actions/github-script@v7
env:
# Pass manual inputs via env for convenience
CURRENT_TAG: ${{ github.event.inputs.current_tag }}
DRY_RUN: ${{ github.event.inputs.dry_run }}
PLACEHOLDER: "<!--DIFF_LINK-->"
with:
script: |
// Updates the current weekly release notes with a compare link to the previous weekly.
// Works for both release-published events and manual (workflow_dispatch) runs.
const owner = context.repo.owner;
const repo = context.repo.repo;
const rx = /^weekly-(\d{4})\.(\d{2})\.(\d{2})$/;
// Determine currentTag:
// 1) Manual input via workflow_dispatch (env.CURRENT_TAG)
// 2) Tag from release event payload
// 3) Fallback: newest weekly pre-release
let currentTag = process.env.CURRENT_TAG || (context.payload?.release?.tag_name) || null;
async function detectLatestWeeklyTag() {
const releases = await github.paginate(github.rest.repos.listReleases, { owner, repo, per_page: 100 });
const cand = releases.find(r => r.prerelease && typeof r.tag_name === 'string' && rx.test(r.tag_name));
return cand?.tag_name || null;
}
if (!currentTag) {
currentTag = await detectLatestWeeklyTag();
}
if (!currentTag || !rx.test(currentTag)) {
core.info(`No weekly tag detected or tag format mismatch ('${currentTag}'). Skipping.`);
return;
}
// Resolve the current release object
let curRel;
try {
const { data } = await github.rest.repos.getReleaseByTag({ owner, repo, tag: currentTag });
curRel = data;
} catch (e) {
core.setFailed(`No release for tag ${currentTag}: ${e.message}`);
return;
}
// If event is a normal release (not pre-release), skip automatically-run case;
// but allow manual override (manual runs can patch any weekly tag).
const isManual = context.eventName === 'workflow_dispatch';
if (!isManual && !curRel.prerelease) {
core.info('Current release is not a pre-release; skipping (auto run).');
return;
}
// Helpers
const toPrevWeeklyTag = (tag) => {
const [, y, m, d] = tag.match(rx);
const dt = new Date(Date.UTC(+y, +m - 1, +d));
const prev = new Date(dt.getTime() - 7 * 24 * 3600 * 1000); // minus 7 days
const iso = prev.toISOString().slice(0, 10); // YYYY-MM-DD
return `weekly-${iso.replace(/-/g, '.')}`; // weekly-YYYY.MM.DD
};
const ymdKey = (t) => t.replace(rx, '$1$2$3'); // YYYYMMDD
async function tagExists(tag) {
try {
await github.rest.git.getRef({ owner, repo, ref: `tags/${tag}` });
return true;
} catch {
return false;
}
}
// Compute previous weekly deterministically, then fall back if needed
let prevTag = toPrevWeeklyTag(currentTag);
if (!(await tagExists(prevTag))) {
core.info(`Computed previous tag ${prevTag} not found; scanning older weeklies...`);
const releases = await github.paginate(github.rest.repos.listReleases, { owner, repo, per_page: 100 });
const curKey = ymdKey(currentTag);
const older = releases
.filter(r => r.prerelease && typeof r.tag_name === 'string' && rx.test(r.tag_name))
.map(r => ({ tag: r.tag_name, key: ymdKey(r.tag_name) }))
.filter(x => x.key < curKey)
.sort((a, b) => b.key.localeCompare(a.key)); // newest older first
if (!older.length) {
core.info('No older weekly found; nothing to do.');
return;
}
prevTag = older[0].tag;
}
const compareUrl = `https://github.com/${owner}/${repo}/compare/${prevTag}...${currentTag}`;
const head = `**Changes since last weekly (${prevTag} → ${currentTag}):**\n${compareUrl}\n`;
if (process.env.DRY_RUN === 'true') {
core.info(`[DRY RUN] Would update release ${currentTag} with: ${compareUrl}`);
return;
}
// Idempotent body update
let body = curRel.body || '';
if (body.includes(compareUrl)) {
core.info('Compare URL already present; done.');
return;
}
const placeholder = process.env.PLACEHOLDER || '<!--DIFF_LINK-->';
if (body.includes(placeholder)) {
body = body.replace(placeholder, compareUrl);
} else if (/\*\*Changes since last weekly:/i.test(body)) {
body = body.replace(/\*\*Changes since last weekly:[^\n]*\n?/i, head + '\n');
} else {
body += (body.endsWith('\n') ? '\n' : '\n\n') + head;
}
await github.rest.repos.updateRelease({ owner, repo, release_id: curRel.id, body });
core.info(`Release notes updated with compare link: ${compareUrl}`);
+4
View File
@@ -115,6 +115,10 @@ if(NOT FREECAD_LIBPACK_USE OR FREECAD_LIBPACK_CHECKFILE_CLBUNDLER OR FREECAD_LIB
# SetupCoin3D can overwrite find_package(Boost) output so keep this after.
SetupBoost()
if(BUILD_BIM)
SetupLark()
endif()
endif()
if(BUILD_VR)
+53
View File
@@ -0,0 +1,53 @@
# - Find the lark library
# This module finds if lark is installed, and sets the following variables
# indicating where it is.
#
# LARK_FOUND - was lark found
# LARK_VERSION - the version of lark found as a string
# LARK_VERSION_MAJOR - the major version number of lark
# LARK_VERSION_MINOR - the minor version number of lark
# LARK_VERSION_PATCH - the patch version number of lark
include(FindPackageHandleStandardArgs)
if(Python3_EXECUTABLE)
message(STATUS "FindLark: Using Python3_EXECUTABLE = ${Python3_EXECUTABLE}")
# try to import lark into Python interpreter
execute_process(
COMMAND "${Python3_EXECUTABLE}" "-c"
"import lark; print(lark.__version__)"
RESULT_VARIABLE _LARK_SEARCH_SUCCESS
OUTPUT_VARIABLE LARK_VERSION
ERROR_VARIABLE _LARK_ERROR_VALUE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message(DEBUG "FindLark: Result = ${_LARK_SEARCH_SUCCESS}")
message(DEBUG "FindLark: Version = ${LARK_VERSION}")
message(DEBUG "FindLark: Error = ${_LARK_ERROR_VALUE}")
if(_LARK_SEARCH_SUCCESS MATCHES 0)
# extract version components
string(REGEX REPLACE "\\." ";" _LARK_VERSION_LIST ${LARK_VERSION})
list(LENGTH _LARK_VERSION_LIST _LARK_VERSION_LIST_LEN)
if(_LARK_VERSION_LIST_LEN GREATER_EQUAL 1)
list(GET _LARK_VERSION_LIST 0 LARK_VERSION_MAJOR)
endif()
if(_LARK_VERSION_LIST_LEN GREATER_EQUAL 2)
list(GET _LARK_VERSION_LIST 1 LARK_VERSION_MINOR)
endif()
if(_LARK_VERSION_LIST_LEN GREATER_EQUAL 3)
list(GET _LARK_VERSION_LIST 2 LARK_VERSION_PATCH)
endif()
else()
message(STATUS "The BIM workbench requires the lark python package / module to be installed")
endif()
else()
message(STATUS "FindLark: Python3_EXECUTABLE not set")
endif()
find_package_handle_standard_args(LARK
REQUIRED_VARS LARK_VERSION
VERSION_VAR LARK_VERSION
)
@@ -221,6 +221,9 @@ macro(PrintFinalReport)
conditional(fmt fmt_FOUND "Sources downloaded to ${fmt_SOURCE_DIR}" "${fmt_VERSION}")
conditional(yaml-cpp yaml-cpp_FOUND "not found" "${yaml-cpp_VERSION}")
conditional(Vtk VTK_FOUND "not found" ${VTK_VERSION})
if(BUILD_BIM)
conditional(Lark LARK_FOUND "not found" "${LARK_VERSION}")
endif()
section_end()
+7
View File
@@ -0,0 +1,7 @@
macro(SetupLark)
# ------------------------------ Lark ------------------------------
find_package(LARK MODULE REQUIRED)
message(STATUS "Found Lark: version ${LARK_VERSION}")
endmacro()
+23 -10
View File
@@ -103,20 +103,33 @@ macro(SetupSalomeSMESH)
set(HDF5_VARIANT "hdf5-serial")
else()
message(STATUS "We guess that libmed was built using hdf5-openmpi version")
set(HDF5_VARIANT "hdf5-openmpi")
set(HDF5_VARIANT "hdf5-openmpi;hdf5_openmpi")
set(HDF5_PREFER_PARALLEL TRUE) # if pkg-config fails, find_package(HDF5) needs this
endif()
pkg_search_module(HDF5 ${HDF5_VARIANT})
if(NOT HDF5_FOUND)
pkg_search_module(PCHDF5 ${HDF5_VARIANT})
if(NOT PCHDF5_FOUND)
find_package(HDF5 REQUIRED)
else()
add_compile_options(${HDF5_CFLAGS})
link_directories(${HDF5_LIBRARY_DIRS})
link_libraries(${HDF5_LIBRARIES})
endif()
check_include_file_cxx(hdf5.h HDF5_FOUND)
if(NOT HDF5_FOUND)
message( FATAL_ERROR "hdf5.h was not found.")
add_compile_options(${PCHDF5_CFLAGS})
link_directories(${PCHDF5_LIBRARY_DIRS})
link_libraries(${PCHDF5_LIBRARIES})
# workaround to define include dir from PCHDF5_CFLAGS (pkg-config PCHDF5_INCLUDEDIR is only filled since hdf5 1.14.6)
set(hdf5_include_path "")
foreach(flag IN LISTS PCHDF5_CFLAGS)
if(flag MATCHES "^-I")
string(REGEX REPLACE "^-I[ ]*" "" flag "${flag}")
list(APPEND hdf5_include_path "${flag}")
endif()
endforeach()
set(_save_INC CMAKE_REQUIRED_INCLUDES)
set(CMAKE_REQUIRED_INCLUDES ${hdf5_include_path})
check_include_file_cxx(hdf5.h HDF5_HEAD_FOUND)
set(CMAKE_REQUIRED_INCLUDES ${_save_INC})
if(NOT HDF5_HEAD_FOUND)
message( FATAL_ERROR "hdf5.h was not found (tested pkg-config ${HDF5_VARIANT}, suggested header location was '${hdf5_include_path}').")
endif()
endif()
# Med Fichier can require MPI
Binary file not shown.
Binary file not shown.
+3 -2
View File
@@ -5,7 +5,7 @@
\pard\nowidctlpar\hyphpar0\sa140\sl276\slmult1\par
\pard\nowidctlpar\hyphpar0\sl276\slmult1\b\fs28 Third-party libraries licenses\b0\fs24\par
\pard\nowidctlpar\hyphpar0\sa140\sl276\slmult1\par
\pard\nowidctlpar\hyphpar0\sl276\slmult1\fs18 The different libraries used in FreeCAD and their respective licenses are described on the\line\fs24{\field{\*\fldinst{HYPERLINK "https://www.freecadweb.org/wiki/Third_Party_Libraries" }}{\fldrslt{\cf2\ul\fs18 Third Party Libraries wiki page}}}\cf0\ulnone\f0\fs18 .\fs24\par
\pard\nowidctlpar\hyphpar0\sl276\slmult1\fs18 The different libraries used in FreeCAD and their respective licenses are described on the\line\fs24{\field{\*\fldinst{HYPERLINK "https://www.freecad.org/wiki/Third_Party_Libraries" }}{\fldrslt{\cf2\ul\fs18 Third Party Libraries wiki page}}}\cf0\ulnone\f0\fs18 .\fs24\par
\par
\pard\noline\nowidctlpar\hyphpar0\sa283\fs12\par
\pard\nowidctlpar\hyphpar0\sl276\slmult1\b\fs18 GNU LIBRARY GENERAL PUBLIC LICENSE\b0\fs24\par
@@ -81,4 +81,5 @@
\pard\nowidctlpar\hyphpar0\sb240\sa180\sl276\slmult1\b\fs24 3D Mouse Support\b0\par
\pard\nowidctlpar\hyphpar0\sb180\sa180\sl276\slmult1\fs18 Development tools and related technology provided under license from 3Dconnexion.(c) 1992 - 2012 3Dconnexion. All rights reserved\fs12\par
}
+1 -5
View File
@@ -34,11 +34,7 @@ These typically need to be modified for each FreeCAD release
#--------------------------------
# get version info from freecadcmd
!system "${FILES_FREECAD}\bin\freecadcmd.exe --safe-mode -c $\"import datetime; print(f'!define COPYRIGHT_YEAR {datetime.date.today().year}')$\">${__FILEDIR__}\version.nsh" = 0
!system "${FILES_FREECAD}\bin\freecadcmd.exe --safe-mode -c $\"print(f'!define APP_VERSION_MAJOR \$\"{App.Version()[0]}\$\"')$\">>${__FILEDIR__}\version.nsh" = 0
!system "${FILES_FREECAD}\bin\freecadcmd.exe --safe-mode -c $\"print(f'!define APP_VERSION_MINOR \$\"{App.Version()[1]}\$\"')$\">>${__FILEDIR__}\version.nsh" = 0
!system "${FILES_FREECAD}\bin\freecadcmd.exe --safe-mode -c $\"print(f'!define APP_VERSION_PATCH \$\"{App.Version()[2]}\$\"')$\">>${__FILEDIR__}\version.nsh" = 0
!system "${FILES_FREECAD}\bin\freecadcmd.exe --safe-mode -c $\"print(f'!define APP_VERSION_REVISION \$\"{App.Version()[3].split()[0]}\$\"')$\">>${__FILEDIR__}\version.nsh" = 0
!system "${FILES_FREECAD}\bin\freecadcmd.exe --safe-mode $\"${__FILEDIR__}\write_version_nsh.py$\"" = 0
!include "${__FILEDIR__}\version.nsh"
!delfile "${__FILEDIR__}\version.nsh"
+1 -1
View File
@@ -7,7 +7,7 @@ Language: English
${LangFileString} TEXT_INSTALL_CURRENTUSER "(Installed for Current User)"
${LangFileString} TEXT_WELCOME "This wizard will guide you through the installation of $(^NameDA), $\r$\n\
${LangFileString} TEXT_WELCOME "This wizard will guide you through the installation of $(^NameDA). $\r$\n\
$\r$\n\
$_CLICK"
@@ -0,0 +1,20 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# this script is meant to be called by nsis installer scripts, it gets version information
# from freecad and writes version.nsh file in the directory the script is located at
import FreeCAD
import datetime
import os
filepath=os.path.join(os.path.dirname(os.path.abspath(__file__)),"version.nsh")
v=FreeCAD.Version()
content=f'''\
!define COPYRIGHT_YEAR {datetime.date.today().year}
!define APP_VERSION_MAJOR "{v[0]}"
!define APP_VERSION_MINOR "{v[1]}"
!define APP_VERSION_PATCH "{v[2]}"
!define APP_VERSION_REVISION "{v[3].split()[0]}"
'''
with open(filepath, "w", encoding="utf-8") as file:
file.writelines(content)
+2 -2
View File
@@ -29,7 +29,7 @@ Source0: freecad-sources.tar.gz
# Maintainers: keep this list of plugins up to date
# List plugins in %%{_libdir}/%%{name}/lib, less '.so' and 'Gui.so', here
%global plugins AssemblyApp AssemblyGui CAMSimulator DraftUtils Fem FreeCAD Import Inspection MatGui Materials Measure Mesh MeshPart Part PartDesignGui Path PathApp PathSimulator Points QtUnitGui ReverseEngineering Robot Sketcher Spreadsheet Start Surface TechDraw Web _PartDesign area flatmesh libDriver libDriverDAT libDriverSTL libDriverUNV libE57Format libMEFISTO2 libSMDS libSMESH libSMESHDS libStdMeshers libarea-native
%global plugins AssemblyApp AssemblyGui CAMSimulator DraftUtils Fem FreeCAD Import Inspection MatGui Materials Measure Mesh MeshPart Part PartDesignGui Path PathApp PathSimulator Points QtUnitGui ReverseEngineering Robot Sketcher Spreadsheet Start Surface TechDraw Web _PartDesign area flatmesh libDriver libDriverDAT libDriverSTL libDriverUNV libE57Format libMEFISTO2 libSMDS libSMESH libSMESHDS libStdMeshers libarea-native tsp_solver
%global exported_libs libOndselSolver
@@ -51,7 +51,7 @@ BuildRequires: gtest-devel gmock-devel
%endif
# Development Libraries
BuildRequires:boost-devel Coin4-devel eigen3-devel freeimage-devel fmt-devel libglvnd-devel libicu-devel libspnav-devel libXmu-devel med-devel mesa-libEGL-devel mesa-libGLU-devel netgen-mesher-devel netgen-mesher-devel-private opencascade-devel openmpi-devel python3 python3-devel python3-matplotlib python3-pivy python3-pybind11 python3-pyside6-devel python3-shiboken6-devel pyside6-tools qt6-qttools-static qt6-qtsvg-devel vtk-devel xerces-c-devel yaml-cpp-devel
BuildRequires:boost-devel Coin4-devel eigen3-devel freeimage-devel fmt-devel libglvnd-devel libicu-devel libspnav-devel libXmu-devel med-devel mesa-libEGL-devel mesa-libGLU-devel netgen-mesher-devel netgen-mesher-devel-private opencascade-devel openmpi-devel python3 python3-devel python3-lark python3-matplotlib python3-pivy python3-pybind11 python3-pyside6-devel python3-shiboken6-devel pyside6-tools qt6-qttools-static qt6-qtsvg-devel vtk-devel xerces-c-devel yaml-cpp-devel
#pcl-devel
%if %{without bundled_smesh}
BuildRequires: smesh-devel
+1
View File
@@ -37,6 +37,7 @@ cmake \
-D OCC_LIBRARY_DIR:FILEPATH="$PREFIX/lib" \
-D Python_EXECUTABLE:FILEPATH="$PYTHON" \
-D Python3_EXECUTABLE:FILEPATH="$PYTHON" \
-D BUILD_DYNAMIC_LINK_PYTHON:BOOL=OFF \
-B build \
-S .
+1
View File
@@ -102,6 +102,7 @@ requirements:
- fmt
- freetype
- hdf5
- lark
- libboost-devel
- matplotlib-base
- noqt5
+1
View File
@@ -55,6 +55,7 @@ packages=(
python3-dev
python3-defusedxml
python3-git
python3-lark
python3-markdown
python3-matplotlib
python3-packaging
+59
View File
@@ -348,6 +348,7 @@ environments:
- conda: https://conda.anaconda.org/conda-forge/linux-64/pyyaml-6.0.2-py311h2dc5d0c_2.conda
- conda: https://conda.anaconda.org/conda-forge/linux-64/qhull-2020.2-h434a139_5.conda
- conda: https://conda.anaconda.org/conda-forge/linux-64/qt6-main-6.8.3-h75f3359_4.conda
- conda: https://conda.anaconda.org/conda-forge/linux-64/qt6-wayland-6.8.3-hf501273_0.conda
- conda: https://conda.anaconda.org/conda-forge/linux-64/rapidjson-1.1.0.post20240409-h3f2d84a_2.conda
- conda: https://conda.anaconda.org/conda-forge/linux-64/rav1e-0.7.1-h8fae777_3.conda
- conda: https://conda.anaconda.org/conda-forge/linux-64/readline-8.2-h8c095d6_2.conda
@@ -767,6 +768,7 @@ environments:
- conda: https://conda.anaconda.org/conda-forge/linux-aarch64/pyyaml-6.0.2-py311h58d527c_2.conda
- conda: https://conda.anaconda.org/conda-forge/linux-aarch64/qhull-2020.2-h70be974_5.conda
- conda: https://conda.anaconda.org/conda-forge/linux-aarch64/qt6-main-6.8.3-he176c03_4.conda
- conda: https://conda.anaconda.org/conda-forge/linux-aarch64/qt6-wayland-6.8.3-h6948401_0.conda
- conda: https://conda.anaconda.org/conda-forge/linux-aarch64/rapidjson-1.1.0.post20240409-h5ad3122_2.conda
- conda: https://conda.anaconda.org/conda-forge/linux-aarch64/readline-8.2-h8382b9d_2.conda
- conda: https://conda.anaconda.org/conda-forge/noarch/requests-2.32.4-pyhd8ed1ab_0.conda
@@ -18879,6 +18881,63 @@ packages:
purls: []
size: 92900449
timestamp: 1750923594107
- conda: https://conda.anaconda.org/conda-forge/linux-64/qt6-wayland-6.8.3-hf501273_0.conda
sha256: 82d09a7bd753766f06b3c81696053a24637b9e33e4f32baf32ca071f51273760
md5: 984c2eefffc5d3937883b10748d16a34
depends:
- __glibc >=2.17,<3.0.a0
- fontconfig >=2.15.0,<3.0a0
- fonts-conda-ecosystem
- freetype >=2.13.3,<3.0a0
- libegl >=1.7.0,<2.0a0
- libgcc >=13
- libgl >=1.7.0,<2.0a0
- libglib >=2.84.0,<3.0a0
- libglx >=1.7.0,<2.0a0
- libopengl >=1.7.0,<2.0a0
- libstdcxx >=13
- libxkbcommon >=1.8.1,<2.0a0
- libzlib >=1.3.1,<2.0a0
- qt6-main 6.8.3.*
- qt6-main >=6.8.3,<6.9.0a0
- wayland >=1.23.1,<2.0a0
- xorg-libx11 >=1.8.12,<2.0a0
- xorg-libxcomposite >=0.4.6,<1.0a0
- xorg-libxext >=1.3.6,<2.0a0
- xorg-libxrandr >=1.5.4,<2.0a0
license: LGPL-3.0-only
license_family: LGPL
purls: []
size: 1550598
timestamp: 1743159191270
- conda: https://conda.anaconda.org/conda-forge/linux-aarch64/qt6-wayland-6.8.3-h6948401_0.conda
sha256: 775a5615e3f763920f91366014a4111c58907694615c1d03752e0efcb5db2fdc
md5: 55b2a18347cd8fc340ecd553c70a8eee
depends:
- fontconfig >=2.15.0,<3.0a0
- fonts-conda-ecosystem
- freetype >=2.13.3,<3.0a0
- libegl >=1.7.0,<2.0a0
- libgcc >=13
- libgl >=1.7.0,<2.0a0
- libglib >=2.84.0,<3.0a0
- libglx >=1.7.0,<2.0a0
- libopengl >=1.7.0,<2.0a0
- libstdcxx >=13
- libxkbcommon >=1.8.1,<2.0a0
- libzlib >=1.3.1,<2.0a0
- qt6-main 6.8.3.*
- qt6-main >=6.8.3,<6.9.0a0
- wayland >=1.23.1,<2.0a0
- xorg-libx11 >=1.8.12,<2.0a0
- xorg-libxcomposite >=0.4.6,<1.0a0
- xorg-libxext >=1.3.6,<2.0a0
- xorg-libxrandr >=1.5.4,<2.0a0
license: LGPL-3.0-only
license_family: LGPL
purls: []
size: 1639641
timestamp: 1743262388133
- pypi: https://files.pythonhosted.org/packages/69/76/37c0ccd5ab968a6a438f9c623aeecc84c202ab2fabc6a8fd927580c15b5a/QtPy-2.4.3-py3-none-any.whl
name: qtpy
version: 2.4.3
+2
View File
@@ -92,6 +92,7 @@ mesa-libgl-cos7-x86_64 = "*"
mesa-libgl-devel-cos7-x86_64 = "*"
mold = "*"
pixman-cos7-x86_64 = "*"
qt6-wayland = "*"
sed = "*"
sysroot_linux-64 = "*"
xorg-x11-server-common-cos7-x86_64 = "*"
@@ -130,6 +131,7 @@ mesa-libgl-devel-cos7-aarch64 = "*"
mesa-libglapi-cos7-aarch64 = "*"
mold = "*"
pixman-cos7-aarch64 = "*"
qt6-wayland = "*"
sed = "*"
sysroot_linux-aarch64 = "*"
xorg-x11-server-common-cos7-aarch64 = "*"
+2
View File
@@ -1,3 +1,5 @@
add_subdirectory(FastSignals)
# Build SalomeMesh for all Platforms since heavily patched
if (BUILD_SMESH)
add_subdirectory(salomesmesh)
+102
View File
@@ -0,0 +1,102 @@
---
Language: Cpp
# BasedOnStyle: WebKit
AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: false
AlignOperands: false
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: false
AfterStruct: true
AfterUnion: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
BreakBeforeBinaryOperators: All
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: true
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 0
CommentPragmas: '^ IWYU pragma:'
BreakBeforeInheritanceComma: true
FixNamespaceComments: true
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
# FixNamespaceComments: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IncludeCategories:
- Regex: '^"(stdafx|PrecompiledHeader)'
Priority: -2
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 4
- Regex: '^(<|"(gtest|isl|json)/)'
Priority: 3
- Regex: '.*'
Priority: 2
IncludeIsMainRegex: '$'
IndentCaseLabels: false
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: 'BEGIN_MESSAGE_MAP_CUSTOM$|BEGIN_MSG_MAP$|BEGIN_SINK_MAP$|BEGIN_MESSAGE_MAP$|BOOST_FIXTURE_TEST_SUITE$|BOOST_AUTO_TEST_SUITE$|BEGIN_DLGRESIZE_MAP$|BEGIN_MSG_MAP_EX$|BEGIN_DDX_MAP$|BEGIN_COM_MAP$|BEGIN_CONNECTION_POINT_MAP$|WTL_BEGIN_LAYOUT_MAP$|WTL_BEGIN_LAYOUT_CONTAINER$'
MacroBlockEnd: 'END_MESSAGE_MAP_CUSTOM$|END_MSG_MAP$|END_SINK_MAP$|END_MESSAGE_MAP$|BOOST_AUTO_TEST_SUITE_END$|END_DLGRESIZE_MAP$|END_DDX_MAP$|END_COM_MAP$|END_CONNECTION_POINT_MAP$|WTL_END_LAYOUT_MAP$|WTL_END_LAYOUT_CONTAINER$'
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 4
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 100
PenaltyReturnTypeOnItsOwnLine: 10000000
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 4
UseTab: Always
IndentPPDirectives: AfterHash
...
+367
View File
@@ -0,0 +1,367 @@
# Prerequisites
*.d
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
*.smod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush
.cr/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# ------------
# Custom Rules
build/
+12
View File
@@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
project(FastSignals)
include(cmake/functions.cmake)
add_subdirectory(libfastsignals)
if(BUILD_FASTSIGNALS_TESTING)
add_subdirectory(tests/libfastsignals_stress_tests)
add_subdirectory(tests/libfastsignals_unit_tests)
endif()
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 iSpring Solutions Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+17
View File
@@ -0,0 +1,17 @@
# FastSignals
Yet another C++ signals and slots library
* Works as drop-in replacement for Boost.Signals2 with the same API
* Has better performance and more compact binary code
* Thread-safe in most operations, including concurrent connects/disconnects/emits
* Implemented with compact, pure C++17 code
[![Build Status](https://travis-ci.org/ispringteam/FastSignals.svg?branch=master)](https://travis-ci.org/ispringteam/FastSignals)
[![License: MIT](https://img.shields.io/badge/License-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT)
## Documentation
* [Why FastSignals?](docs/why-fastsignals.md)
* [Simple Examples](docs/simple-examples.md)
* [Migration from Boost.Signals2](docs/migration-from-boost-signals2.md)
+24
View File
@@ -0,0 +1,24 @@
# Function to add a library target.
function(custom_add_library_from_dir TARGET)
# Gather files from the current directory
file(GLOB TARGET_SRC "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
add_library(${TARGET} ${TARGET_SRC})
endfunction()
# Function to add an executable target.
function(custom_add_executable_from_dir TARGET)
# Gather files from the current directory
file(GLOB TARGET_SRC "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
add_executable(${TARGET} ${TARGET_SRC})
endfunction()
# Function to add an executable target containing tests for a library.
function(custom_add_test_from_dir TARGET LIBRARY)
custom_add_executable_from_dir(${TARGET})
# Add path to Catch framework header
target_include_directories(${TARGET} PRIVATE "${CMAKE_SOURCE_DIR}/libs/catch")
# Link with the library being tested
target_link_libraries(${TARGET} ${LIBRARY})
# Register the executable with CMake as a test set
add_test(${TARGET} ${TARGET})
endfunction()
+94
View File
@@ -0,0 +1,94 @@
# Function bind_weak
## Usage
* Use `fastsignals::bind_weak` instead of `std::bind` to ensure that nothing happens if method called when binded object already destroyed
* Pass pointer to T class method as first argument, `shared_ptr<T>` or `weak_ptr<T>` as second argument
* Example: `bind_weak(&Document::save(), document, std::placeholders::_1)`, where `document` is a `weak_ptr<Document>` or `shared_ptr<Document>`
## Weak this idiom
The `fastsignals::bind_weak(...)` function implements "weak this" idiom. This idiom helps to avoid dangling pointers and memory access wiolations in asynchronous and/or multithreaded programs.
In the following example, we use weak this idiom to avoid using dangling pointer wehn calling `print()` method of the `Enityt`:
```cpp
struct Entity : std::enable_shared_from_this<Entity>
{
int value = 42;
void print()
{
std::cout << "print called, num = " << value << std::endl;
}
std::function<void()> print_later()
{
// ! weak this idiom here !
auto weak_this = weak_from_this();
return [weak_this] {
if (auto shared_this = weak_this.lock())
{
shared_this->print();
}
};
}
};
int main()
{
auto entity = std::make_shared<Entity>();
auto print = entity->print_later();
// Prints OK.
print();
// Prints nothing - last shared_ptr to the Entity destroyed, so `weak_this.lock()` will return nullptr.
entity = nullptr;
print();
}
```
## Using bind_weak to avoid signal receiver lifetime issues
In the following example, `Entity::print()` method connected to the signal. Signal emmited once before and once after the `Entity` instance destroyed. However, no memory access violation happens: once `Entity` destoryed, no slot will be called because `bind_weak` doesn't call binded method if it cannot lock `std::weak_ptr` to binded object. The second `event()` expression just does nothing.
```cpp
#include <fastsignals/signal.h>
#include <fastsignals/bind_weak.h>
#include <iostream>
using VoidSignal = fastsignals::signal<void()>;
using VoidSlot = VoidSignal::slot_type;
struct Entity : std::enable_shared_from_this<Entity>
{
int value = 42;
VoidSlot get_print_slot()
{
// Here fastsignals::bind_weak() used instead of std::bind.
return fastsignals::bind_weak(&Entity::print, weak_from_this());
}
void print()
{
std::cout << "print called, num = " << value << std::endl;
}
};
int main()
{
VoidSignal event;
auto entity = std::make_shared<Entity>();
event.connect(entity->get_print_slot());
// Here slot called - it prints `slot called, num = 42`
event();
entity = nullptr;
// Here nothing happens - no exception, no slot call.
event();
}
```
@@ -0,0 +1,163 @@
# Migration from Boost.Signals2
This guide helps to migrate large codebase from Boost.Signals2 to `FastSignals` signals/slots library. It helps to solve known migration issues in the right way.
During migrations, you will probably face with following things:
* You code uses `boost::signals2::` namespace and `<boost/signals2.hpp>` header directly
* You code uses third-party headers included implicitly by the `<boost/signals2.hpp>` header
## Reasons migrate from Boost.Signals2 to FastSignals
FastSignals API mostly compatible with Boost.Signals2 - there are differences, and all differences has their reasons explained below.
Comparing to Boost.Signals2, FastSignals has following pros:
* FastSignals is not header-only - so binary code will be more compact
* FastSignals implemented using C++17 with variadic templates, `constexpr if` and other modern metaprogramming techniques - so it compiles faster and, again, binary code will be more compact
* FastSignals probably will faster than Boost.Signals2 for your codebase because with FastSignals you don't pay for things that you don't use, with one exception: you always pay for the multithreading support
## Step 1: Create header with aliases
## Step 2: Rebuild and fix compile errors
### 2.1 Add missing includes
Boost.Signals2 is header-only library. It includes a lot of STL/Boost stuff while FastSignals does not:
```cpp
#include <boost/signals2.hpp>
// Also includes std::map, boost::variant, boost::optional, etc.
// Compiled OK even without `#include <map>`!
std::map CreateMyMap();
```
With FastSignals, you must include headers like `<map>` manually. The following table shows which files should be included explicitly if you see compile erros after migration.
| Class | Header |
|--------------------|:--------------------------------------:|
| std::map | `#include <map>` |
| boost::variant | `#include <boost/variant/variant.hpp>` |
| boost::optional | `#include <boost/optional/optional.hpp>` |
| boost::scoped_ptr | `#include <boost/scoped_ptr.hpp>` |
| boost::noncopyable | `#include <boost/noncopyable.hpp>` |
| boost::bind | `#include <boost/bind.hpp>` |
| boost::function | `#include <boost/function.hpp>` |
If you just want to compile you code, you can add following includes in you `signals.h` header:
```cpp
// WARNING: [libfastsignals] we do not recommend to include following extra headers.
#include <map>
#include <boost/variant/variant.hpp>
#include <boost/optional/optional.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/noncopyable.hpp>
#include <boost/bind.hpp>
#include <boost/function.hpp>
```
### 2.2 Remove redundant returns for void signals
With Boost.Signals2, following code compiled without any warning:
```cpp
boost::signals2::signal<void()> event;
event.connect([] {
return true;
});
```
With FastSignals, slot cannot return non-void value when for `signal<void(...)>`. You must fix your code: just remove returns from your slots or add lambdas to wrap slot and ignore it result.
### 2.3 Replace track() and track_foreign() with bind_weak_ptr()
Boost.Signals2 [can track connected objects lifetype](https://www.boost.org/doc/libs/1_55_0/doc/html/signals2/tutorial.html#idp204830936) using `track(...)` and `track_foreign(...)` methods. In the following example `Entity` created with `make_shared`, and `Entity::get_print_slot()` creates slot function which tracks weak pointer to Entity:
```cpp
#include <boost/signals2.hpp>
#include <iostream>
#include <memory>
using VoidSignal = boost::signals2::signal<void()>;
using VoidSlot = VoidSignal::slot_type;
struct Entity : std::enable_shared_from_this<Entity>
{
int value = 42;
VoidSlot get_print_slot()
{
// Here track() tracks object itself.
return VoidSlot(std::bind(&Entity::print, this)).track_foreign(shared_from_this());
}
void print()
{
std::cout << "print called, num = " << value << std::endl;
}
};
int main()
{
VoidSignal event;
auto entity = std::make_shared<Entity>();
event.connect(entity->get_print_slot());
// Here slot called - it prints `print called, num = 42`
event();
entity = nullptr;
// This call does nothing.
event();
}
```
FastSignals uses another approach: `bind_weak` function:
```cpp
#include <fastsignals/bind_weak.h>
#include <iostream>
using VoidSignal = fastsignals::signal<void()>;
using VoidSlot = VoidSignal::slot_type;
struct Entity : std::enable_shared_from_this<Entity>
{
int value = 42;
VoidSlot get_print_slot()
{
// Here fastsignals::bind_weak() used instead of std::bind.
return fastsignals::bind_weak(&Entity::print, weak_from_this());
}
void print()
{
std::cout << "print called, num = " << value << std::endl;
}
};
int main()
{
VoidSignal event;
auto entity = std::make_shared<Entity>();
event.connect(entity->get_print_slot());
// Here slot called - it prints `slot called, num = 42`
event();
entity = nullptr;
// Here nothing happens - no exception, no slot call.
event();
}
```
### FastSignals Differences in Result Combiners
## Step 3: Run Tests
Run all automated tests that you have (unit tests, integration tests, system tests, stress tests, benchmarks, UI tests).
Probably you will see no errors. If you see any, please report an issue.
+55
View File
@@ -0,0 +1,55 @@
# Simple Examples
>If you are not familar with Boost.Signals2, please read [Boost.Signals2: Connections](https://theboostcpplibraries.com/boost.signals2-connections)
## Example with signal&lt;&gt; and connection
```cpp
// Creates signal and connects 1 slot, calls 2 times, disconnects, calls again.
// Outputs:
// 13
// 17
#include "libfastsignals/signal.h"
using namespace fastsignals;
int main()
{
signal<void(int)> valueChanged;
connection conn;
conn = valueChanged.connect([](int value) {
cout << value << endl;
});
valueChanged(13);
valueChanged(17);
conn.disconnect();
valueChanged(42);
}
```
## Example with scoped_connection
```cpp
// Creates signal and connects 1 slot, calls 2 times, calls again after scoped_connection destroyed.
// - note: scoped_connection closes connection in destructor
// Outputs:
// 13
// 17
#include "libfastsignals/signal.h"
using namespace fastsignals;
int main()
{
signal<void(int)> valueChanged;
{
scoped_connection conn;
conn = valueChanged.connect([](int value) {
cout << value << endl;
});
valueChanged(13);
valueChanged(17);
}
valueChanged(42);
}
```
+40
View File
@@ -0,0 +1,40 @@
# Why FastSignals?
FastSignals is a C++17 signals/slots implementation which API is compatible with Boost.Signals2.
FastSignals pros:
* Faster than Boost.Signals2
* Has more compact binary code
* Has the same API as Boost.Signals2
FastSignals cons:
* Supports only C++17 compatible compilers: Visual Studio 2017, modern Clang, modern GCC
* Lacks a few rarely used features presented in Boost.Signals2
* No access to connection from slot with `signal::connect_extended` method
* No connected object tracking with `slot::track` method
* Use [bind_weak](bind_weak.md) instead
* No temporary signal blocking with `shared_connection_block` class
* Cannot disconnect equivalent slots since no `disconnect(slot)` function overload
* Any other API difference is a bug - please report it!
See also [Migration from Boost.Signals2](migration-from-boost-signals2.md).
## Benchmark results
Directory `tests/libfastsignals_bench` contains simple benchmark with compares two signal/slot implementations:
* Boost.Signals2
* libfastsignals
Benchmark compairs performance when signal emitted frequently with 0, 1 and 8 active connections. In these cases libfastsignals is 3-6 times faster.
```
*** Results:
measure emit_boost emit_fastsignals
emit_boost/0 1.00 3.00
emit_boost/1 1.00 5.76
emit_boost/8 1.00 3.70
***
```
@@ -0,0 +1,5 @@
file(GLOB LIBFASTSIGNALS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h")
add_library(libfastsignals STATIC ${LIBFASTSIGNALS_SRC})
set_target_properties(libfastsignals PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_include_directories(libfastsignals INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include")
@@ -0,0 +1,79 @@
#pragma once
#include <functional>
#include <memory>
#include <type_traits>
namespace fastsignals
{
namespace detail
{
template <class ReturnType, class ClassType, bool AddConst, class... Args>
struct weak_binder
{
using ConstMethodType = ReturnType (ClassType::*)(Args... args) const;
using NonConstMethodType = ReturnType (ClassType::*)(Args... args);
using MethodType = std::conditional_t<AddConst, ConstMethodType, NonConstMethodType>;
using WeakPtrType = std::weak_ptr<ClassType>;
weak_binder(MethodType pMethod, WeakPtrType&& pObject)
: m_pMethod(pMethod)
, m_pObject(std::move(pObject))
{
}
ReturnType operator()(Args... args) const
{
if (auto pThis = m_pObject.lock())
{
return (pThis.get()->*m_pMethod)(std::forward<Args>(args)...);
}
return ReturnType();
}
MethodType m_pMethod;
WeakPtrType m_pObject;
};
} // namespace detail
/// Weak this binding of non-const methods.
template <typename ReturnType, typename ClassType, typename... Params, typename... Args>
decltype(auto) bind_weak(ReturnType (ClassType::*memberFn)(Params... args), std::shared_ptr<ClassType> const& pThis, Args... args)
{
using weak_binder_alias = detail::weak_binder<ReturnType, ClassType, false, Params...>;
weak_binder_alias invoker(memberFn, std::weak_ptr<ClassType>(pThis));
return std::bind(invoker, args...);
}
/// Weak this binding of const methods.
template <typename ReturnType, typename ClassType, typename... Params, typename... Args>
decltype(auto) bind_weak(ReturnType (ClassType::*memberFn)(Params... args) const, std::shared_ptr<ClassType> const& pThis, Args... args)
{
using weak_binder_alias = detail::weak_binder<ReturnType, ClassType, true, Params...>;
weak_binder_alias invoker(memberFn, std::weak_ptr<ClassType>(pThis));
return std::bind(invoker, args...);
}
/// Weak this binding of non-const methods.
template <typename ReturnType, typename ClassType, typename... Params, typename... Args>
decltype(auto) bind_weak(ReturnType (ClassType::*memberFn)(Params... args), std::weak_ptr<ClassType> pThis, Args... args)
{
using weak_binder_alias = detail::weak_binder<ReturnType, ClassType, false, Params...>;
weak_binder_alias invoker(memberFn, std::move(pThis));
return std::bind(invoker, args...);
}
/// Weak this binding of const methods.
template <typename ReturnType, typename ClassType, typename... Params, typename... Args>
decltype(auto) bind_weak(ReturnType (ClassType::*memberFn)(Params... args) const, std::weak_ptr<ClassType> pThis, Args... args)
{
using weak_binder_alias = detail::weak_binder<ReturnType, ClassType, true, Params...>;
weak_binder_alias invoker(memberFn, std::move(pThis));
return std::bind(invoker, args...);
}
} // namespace fastsignals
@@ -0,0 +1,40 @@
#pragma once
#include <optional>
namespace fastsignals
{
/**
* This results combiner reduces results collection into last value of this collection.
* In other words, it keeps only result of the last slot call.
*/
template <class T>
class optional_last_value
{
public:
using result_type = std::optional<T>;
template <class TRef>
void operator()(TRef&& value)
{
m_result = std::forward<TRef>(value);
}
result_type get_value() const
{
return m_result;
}
private:
result_type m_result = {};
};
template <>
class optional_last_value<void>
{
public:
using result_type = void;
};
} // namespace fastsignals
@@ -0,0 +1,116 @@
#pragma once
#include "signal_impl.h"
namespace fastsignals
{
// Connection keeps link between signal and slot and can disconnect them.
// Disconnect operation is thread-safe: any thread can disconnect while
// slots called on other thread.
// This class itself is not thread-safe: you can't use the same connection
// object from different threads at the same time.
class connection
{
public:
connection() noexcept;
explicit connection(detail::signal_impl_weak_ptr storage, uint64_t id) noexcept;
connection(const connection& other) noexcept;
connection& operator=(const connection& other) noexcept;
connection(connection&& other) noexcept;
connection& operator=(connection&& other) noexcept;
~connection() = default;
bool connected() const noexcept;
void disconnect() noexcept;
protected:
detail::signal_impl_weak_ptr m_storage;
uint64_t m_id = 0;
};
// Connection class that supports blocking callback execution
class advanced_connection : public connection
{
public:
struct advanced_connection_impl
{
void block() noexcept;
void unblock() noexcept;
bool is_blocked() const noexcept;
private:
std::atomic<int> m_blockCounter {0};
};
using impl_ptr = std::shared_ptr<advanced_connection_impl>;
advanced_connection() noexcept;
explicit advanced_connection(connection&& conn, impl_ptr&& impl) noexcept;
advanced_connection(const advanced_connection&) noexcept;
advanced_connection& operator=(const advanced_connection&) noexcept;
advanced_connection(advanced_connection&& other) noexcept;
advanced_connection& operator=(advanced_connection&& other) noexcept;
~advanced_connection() = default;
protected:
impl_ptr m_impl;
};
// Blocks advanced connection, so its callback will not be executed
class shared_connection_block
{
public:
shared_connection_block(const advanced_connection& connection = advanced_connection(), bool initially_blocked = true) noexcept;
shared_connection_block(const shared_connection_block& other) noexcept;
shared_connection_block(shared_connection_block&& other) noexcept;
shared_connection_block& operator=(const shared_connection_block& other) noexcept;
shared_connection_block& operator=(shared_connection_block&& other) noexcept;
~shared_connection_block();
void block() noexcept;
void unblock() noexcept;
bool blocking() const noexcept;
private:
void increment_if_blocked() const noexcept;
std::weak_ptr<advanced_connection::advanced_connection_impl> m_connection;
std::atomic<bool> m_blocked {false};
};
// Scoped connection keeps link between signal and slot and disconnects them in destructor.
// Scoped connection is movable, but not copyable.
class scoped_connection : public connection
{
public:
scoped_connection() noexcept;
scoped_connection(const connection& conn) noexcept;
scoped_connection(connection&& conn) noexcept;
scoped_connection(const advanced_connection& conn) = delete;
scoped_connection(advanced_connection&& conn) noexcept = delete;
scoped_connection(const scoped_connection&) = delete;
scoped_connection& operator=(const scoped_connection&) = delete;
scoped_connection(scoped_connection&& other) noexcept;
scoped_connection& operator=(scoped_connection&& other) noexcept;
~scoped_connection();
connection release() noexcept;
};
// scoped connection for advanced connections
class advanced_scoped_connection : public advanced_connection
{
public:
advanced_scoped_connection() noexcept;
advanced_scoped_connection(const advanced_connection& conn) noexcept;
advanced_scoped_connection(advanced_connection&& conn) noexcept;
advanced_scoped_connection(const advanced_scoped_connection&) = delete;
advanced_scoped_connection& operator=(const advanced_scoped_connection&) = delete;
advanced_scoped_connection(advanced_scoped_connection&& other) noexcept;
advanced_scoped_connection& operator=(advanced_scoped_connection&& other) noexcept;
~advanced_scoped_connection();
advanced_connection release() noexcept;
};
} // namespace fastsignals
@@ -0,0 +1,54 @@
#pragma once
#include "function_detail.h"
namespace fastsignals
{
// Derive your class from not_directly_callable to prevent function from wrapping it using its template constructor
// Useful if your class provides custom operator for casting to function
struct not_directly_callable
{
};
template <class Fn, class Function, class Return, class... Arguments>
using enable_if_callable_t = typename std::enable_if_t<
!std::is_same_v<std::decay_t<Fn>, Function> && !std::is_base_of_v<not_directly_callable, std::decay_t<Fn>> && std::is_same_v<std::invoke_result_t<Fn, Arguments...>, Return>>;
template <class Signature>
class function;
// Compact function class - causes minimal code bloat when compiled.
// Replaces std::function in this library.
template <class Return, class... Arguments>
class function<Return(Arguments...)>
{
public:
function() = default;
function(const function& other) = default;
function(function&& other) noexcept = default;
function& operator=(const function& other) = default;
function& operator=(function&& other) noexcept = default;
template <class Fn, typename = enable_if_callable_t<Fn, function<Return(Arguments...)>, Return, Arguments...>>
function(Fn&& function) noexcept(detail::is_noexcept_packed_function_init<Fn, Return, Arguments...>)
{
m_packed.init<Fn, Return, Arguments...>(std::forward<Fn>(function));
}
Return operator()(Arguments&&... args) const
{
auto& proxy = m_packed.get<Return(Arguments...)>();
return proxy(std::forward<Arguments>(args)...);
}
detail::packed_function release() noexcept
{
return std::move(m_packed);
}
private:
detail::packed_function m_packed;
};
} // namespace fastsignals
@@ -0,0 +1,164 @@
#pragma once
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <type_traits>
#include <utility>
namespace fastsignals::detail
{
/// Buffer for callable object in-place construction,
/// helps to implement Small Buffer Optimization.
static constexpr size_t inplace_buffer_size = (sizeof(int) == sizeof(void*) ? 8 : 6) * sizeof(void*);
/// Structure that has size enough to keep type "T" including vtable.
template <class T>
struct type_container
{
T data;
};
/// Type that has enough space to keep type "T" (including vtable) with suitable alignment.
using function_buffer_t = std::aligned_storage_t<inplace_buffer_size>;
/// Constantly is true if callable fits function buffer, false otherwise.
template <class T>
inline constexpr bool fits_inplace_buffer = (sizeof(type_container<T>) <= inplace_buffer_size);
// clang-format off
/// Constantly is true if callable fits function buffer and can be safely moved, false otherwise
template <class T>
inline constexpr bool can_use_inplace_buffer =
fits_inplace_buffer<T> &&
std::is_nothrow_move_constructible_v<T>;
// clang format on
/// Type that is suitable to keep copy of callable object.
/// - equal to pointer-to-function if Callable is pointer-to-function
/// - otherwise removes const/volatile and references to allow copying callable.
template <class Callable>
using callable_copy_t = std::conditional_t<std::is_function_v<std::remove_reference_t<Callable>>,
Callable,
std::remove_cv_t<std::remove_reference_t<Callable>>>;
class base_function_proxy
{
public:
virtual ~base_function_proxy() = default;
virtual base_function_proxy* clone(void* buffer) const = 0;
virtual base_function_proxy* move(void* buffer) noexcept = 0;
};
template <class Signature>
class function_proxy;
template <class Return, class... Arguments>
class function_proxy<Return(Arguments...)> : public base_function_proxy
{
public:
virtual Return operator()(Arguments&&...) = 0;
};
template <class Callable, class Return, class... Arguments>
class function_proxy_impl final : public function_proxy<Return(Arguments...)>
{
public:
// If you see this error, probably your function returns value and you're trying to
// connect it to `signal<void(...)>`. Just remove return value from callback.
static_assert(std::is_same_v<std::invoke_result_t<Callable, Arguments...>, Return>,
"cannot construct function<> class from callable object with different return type");
template <class FunctionObject>
explicit function_proxy_impl(FunctionObject&& function)
: m_callable(std::forward<FunctionObject>(function))
{
}
Return operator()(Arguments&&... args) final
{
return m_callable(std::forward<Arguments>(args)...);
}
base_function_proxy* clone(void* buffer) const final
{
if constexpr (can_use_inplace_buffer<function_proxy_impl>)
{
return new (buffer) function_proxy_impl(*this);
}
else
{
(void)buffer;
return new function_proxy_impl(*this);
}
}
base_function_proxy* move(void* buffer) noexcept final
{
if constexpr (can_use_inplace_buffer<function_proxy_impl>)
{
base_function_proxy* moved = new (buffer) function_proxy_impl(std::move(*this));
this->~function_proxy_impl();
return moved;
}
else
{
(void)buffer;
return this;
}
}
private:
callable_copy_t<Callable> m_callable;
};
template <class Fn, class Return, class... Arguments>
inline constexpr bool is_noexcept_packed_function_init = can_use_inplace_buffer<function_proxy_impl<Fn, Return, Arguments...>>;
class packed_function final
{
public:
packed_function() = default;
packed_function(packed_function&& other) noexcept;
packed_function(const packed_function& other);
packed_function& operator=(packed_function&& other) noexcept;
packed_function& operator=(const packed_function& other);
~packed_function() noexcept;
// Initializes packed function.
// Cannot be called without reset().
template <class Callable, class Return, class... Arguments>
void init(Callable&& function) noexcept(is_noexcept_packed_function_init<Callable, Return, Arguments...>)
{
using proxy_t = function_proxy_impl<Callable, Return, Arguments...>;
assert(m_proxy == nullptr);
if constexpr (can_use_inplace_buffer<proxy_t>)
{
m_proxy = new (&m_buffer) proxy_t{ std::forward<Callable>(function) };
}
else
{
m_proxy = new proxy_t{ std::forward<Callable>(function) };
}
}
template <class Signature>
function_proxy<Signature>& get() const
{
return static_cast<function_proxy<Signature>&>(unwrap());
}
void reset() noexcept;
private:
base_function_proxy* move_proxy_from(packed_function&& other) noexcept;
base_function_proxy* clone_proxy_from(const packed_function &other);
base_function_proxy& unwrap() const;
bool is_buffer_allocated() const noexcept;
function_buffer_t m_buffer[1] = {};
base_function_proxy* m_proxy = nullptr;
};
} // namespace fastsignals::detail
@@ -0,0 +1,151 @@
#pragma once
#include "combiners.h"
#include "connection.h"
#include "function.h"
#include "signal_impl.h"
#include "type_traits.h"
#include <type_traits>
namespace fastsignals
{
template <class Signature, template <class T> class Combiner = optional_last_value>
class signal;
struct advanced_tag
{
};
/// Signal allows to fire events to many subscribers (slots).
/// In other words, it implements one-to-many relation between event and listeners.
/// Signal implements observable object from Observable pattern.
template <class Return, class... Arguments, template <class T> class Combiner>
class signal<Return(Arguments...), Combiner> : private not_directly_callable
{
public:
using signature_type = Return(signal_arg_t<Arguments>...);
using slot_type = function<signature_type>;
using combiner_type = Combiner<Return>;
using result_type = typename combiner_type::result_type;
signal()
: m_slots(std::make_shared<detail::signal_impl>())
{
}
/// No copy construction
signal(const signal&) = delete;
/// Moves signal from other. Any operations on other except destruction, move, and swap are invalid
signal(signal&& other) = default;
/// No copy assignment
signal& operator=(const signal&) = delete;
/// Moves signal from other. Any operations on other except destruction, move, and swap are invalid
signal& operator=(signal&& other) = default;
/**
* connect(slot) method subscribes slot to signal emission event.
* Each time you call signal as functor, all slots are also called with given arguments.
* @returns connection - object which manages signal-slot connection lifetime
*/
connection connect(slot_type slot)
{
const uint64_t id = m_slots->add(slot.release());
return connection(m_slots, id);
}
/**
* connect(slot, advanced_tag) method subscribes slot to signal emission event with the ability to temporarily block slot execution
* Each time you call signal as functor, all non-blocked slots are also called with given arguments.
* You can temporarily block slot execution using shared_connection_block
* @returns advanced_connection - object which manages signal-slot connection lifetime
*/
advanced_connection connect(slot_type slot, advanced_tag)
{
static_assert(std::is_void_v<Return>, "Advanced connect can only be used with slots returning void (implementation limitation)");
auto conn_impl = std::make_shared<advanced_connection::advanced_connection_impl>();
slot_type slot_impl = [this, slot, weak_conn_impl = std::weak_ptr(conn_impl)](signal_arg_t<Arguments>... args) {
(void)this;
auto conn_impl = weak_conn_impl.lock();
if (!conn_impl || !conn_impl->is_blocked())
{
slot(args...);
}
};
auto conn = connect(std::move(slot_impl));
return advanced_connection(std::move(conn), std::move(conn_impl));
}
/**
* disconnect_all_slots() method disconnects all slots from signal emission event.
*/
void disconnect_all_slots() noexcept
{
m_slots->remove_all();
}
/**
* num_slots() method returns number of slots attached to this singal
*/
[[nodiscard]] std::size_t num_slots() const noexcept
{
return m_slots->count();
}
/**
* empty() method returns true if signal has any slots attached
*/
[[nodiscard]] bool empty() const noexcept
{
return m_slots->count() == 0;
}
/**
* operator(args...) calls all slots connected to this signal.
* Logically, it fires signal emission event.
*/
result_type operator()(signal_arg_t<Arguments>... args) const
{
return detail::signal_impl_ptr(m_slots)->invoke<combiner_type, result_type, signature_type, signal_arg_t<Arguments>...>(args...);
}
void swap(signal& other) noexcept
{
m_slots.swap(other.m_slots);
}
/**
* Allows using signals as slots for another signal
*/
operator slot_type() const noexcept
{
return [weakSlots = detail::signal_impl_weak_ptr(m_slots)](signal_arg_t<Arguments>... args) {
if (auto slots = weakSlots.lock())
{
return slots->invoke<combiner_type, result_type, signature_type, signal_arg_t<Arguments>...>(args...);
}
};
}
private:
detail::signal_impl_ptr m_slots;
};
} // namespace fastsignals
namespace std
{
// free swap function, findable by ADL
template <class Signature, template <class T> class Combiner>
void swap(
::fastsignals::signal<Signature, Combiner>& sig1,
::fastsignals::signal<Signature, Combiner>& sig2)
{
sig1.swap(sig2);
}
} // namespace std
@@ -0,0 +1,59 @@
#pragma once
#include "function_detail.h"
#include "spin_mutex.h"
#include <memory>
#include <vector>
namespace fastsignals::detail
{
class signal_impl
{
public:
uint64_t add(packed_function fn);
void remove(uint64_t id) noexcept;
void remove_all() noexcept;
size_t count() const noexcept;
template <class Combiner, class Result, class Signature, class... Args>
Result invoke(Args... args) const
{
packed_function slot;
size_t slotIndex = 0;
uint64_t slotId = 1;
if constexpr (std::is_same_v<Result, void>)
{
while (get_next_slot(slot, slotIndex, slotId))
{
slot.get<Signature>()(std::forward<Args>(args)...);
}
}
else
{
Combiner combiner;
while (get_next_slot(slot, slotIndex, slotId))
{
combiner(slot.get<Signature>()(std::forward<Args>(args)...));
}
return combiner.get_value();
}
}
private:
bool get_next_slot(packed_function& slot, size_t& expectedIndex, uint64_t& nextId) const;
mutable spin_mutex m_mutex;
std::vector<packed_function> m_functions;
std::vector<uint64_t> m_ids;
uint64_t m_nextId = 1;
};
using signal_impl_ptr = std::shared_ptr<signal_impl>;
using signal_impl_weak_ptr = std::weak_ptr<signal_impl>;
} // namespace fastsignals::detail
@@ -0,0 +1,38 @@
#pragma once
#include <atomic>
namespace fastsignals::detail
{
class spin_mutex
{
public:
spin_mutex() = default;
spin_mutex(const spin_mutex&) = delete;
spin_mutex& operator=(const spin_mutex&) = delete;
spin_mutex(spin_mutex&&) = delete;
spin_mutex& operator=(spin_mutex&&) = delete;
inline bool try_lock() noexcept
{
return !m_busy.test_and_set(std::memory_order_acquire);
}
inline void lock() noexcept
{
while (!try_lock())
{
/* do nothing */;
}
}
inline void unlock() noexcept
{
m_busy.clear(std::memory_order_release);
}
private:
std::atomic_flag m_busy = ATOMIC_FLAG_INIT;
};
} // namespace fastsignals::detail
@@ -0,0 +1,24 @@
#pragma once
namespace fastsignals
{
namespace detail
{
template <typename T>
struct signal_arg
{
using type = const T&;
};
template <typename U>
struct signal_arg<U&>
{
using type = U&;
};
} // namespace detail
template <typename T>
using signal_arg_t = typename detail::signal_arg<T>::type;
} // namespace fastsignals
@@ -0,0 +1,251 @@
#include "../include/fastsignals/connection.h"
namespace fastsignals
{
namespace
{
auto get_advanced_connection_impl(const advanced_connection& connection) noexcept
{
struct advanced_connection_impl_getter : private advanced_connection
{
advanced_connection_impl_getter(const advanced_connection& connection) noexcept
: advanced_connection(connection)
{
}
using advanced_connection::m_impl;
};
return advanced_connection_impl_getter(connection).m_impl;
}
} // namespace
connection::connection(connection&& other) noexcept
: m_storage(other.m_storage)
, m_id(other.m_id)
{
other.m_storage.reset();
other.m_id = 0;
}
connection::connection(detail::signal_impl_weak_ptr storage, uint64_t id) noexcept
: m_storage(std::move(storage))
, m_id(id)
{
}
connection::connection() noexcept = default;
connection::connection(const connection& other) noexcept = default;
connection& connection::operator=(connection&& other) noexcept
{
m_storage = other.m_storage;
m_id = other.m_id;
other.m_storage.reset();
other.m_id = 0;
return *this;
}
connection& connection::operator=(const connection& other) noexcept = default;
bool connection::connected() const noexcept
{
return (m_id != 0);
}
void connection::disconnect() noexcept
{
if (auto storage = m_storage.lock())
{
storage->remove(m_id);
m_storage.reset();
}
m_id = 0;
}
scoped_connection::scoped_connection(connection&& conn) noexcept
: connection(std::move(conn))
{
}
scoped_connection::scoped_connection(const connection& conn) noexcept
: connection(conn)
{
}
scoped_connection::scoped_connection() noexcept = default;
scoped_connection::scoped_connection(scoped_connection&& other) noexcept = default;
scoped_connection& scoped_connection::operator=(scoped_connection&& other) noexcept
{
disconnect();
static_cast<connection&>(*this) = std::move(other);
return *this;
}
scoped_connection::~scoped_connection()
{
disconnect();
}
connection scoped_connection::release() noexcept
{
connection conn = std::move(static_cast<connection&>(*this));
return conn;
}
bool advanced_connection::advanced_connection_impl::is_blocked() const noexcept
{
return m_blockCounter.load(std::memory_order_acquire) != 0;
}
void advanced_connection::advanced_connection_impl::block() noexcept
{
++m_blockCounter;
}
void advanced_connection::advanced_connection_impl::unblock() noexcept
{
--m_blockCounter;
}
advanced_connection::advanced_connection() noexcept = default;
advanced_connection::advanced_connection(connection&& conn, impl_ptr&& impl) noexcept
: connection(std::move(conn))
, m_impl(std::move(impl))
{
}
advanced_connection::advanced_connection(const advanced_connection&) noexcept = default;
advanced_connection::advanced_connection(advanced_connection&& other) noexcept = default;
advanced_connection& advanced_connection::operator=(const advanced_connection&) noexcept = default;
advanced_connection& advanced_connection::operator=(advanced_connection&& other) noexcept = default;
shared_connection_block::shared_connection_block(const advanced_connection& connection, bool initially_blocked) noexcept
: m_connection(get_advanced_connection_impl(connection))
{
if (initially_blocked)
{
block();
}
}
shared_connection_block::shared_connection_block(const shared_connection_block& other) noexcept
: m_connection(other.m_connection)
, m_blocked(other.m_blocked.load(std::memory_order_acquire))
{
increment_if_blocked();
}
shared_connection_block::shared_connection_block(shared_connection_block&& other) noexcept
: m_connection(other.m_connection)
, m_blocked(other.m_blocked.load(std::memory_order_acquire))
{
other.m_connection.reset();
other.m_blocked.store(false, std::memory_order_release);
}
shared_connection_block& shared_connection_block::operator=(const shared_connection_block& other) noexcept
{
if (&other != this)
{
unblock();
m_connection = other.m_connection;
m_blocked = other.m_blocked.load(std::memory_order_acquire);
increment_if_blocked();
}
return *this;
}
shared_connection_block& shared_connection_block::operator=(shared_connection_block&& other) noexcept
{
if (&other != this)
{
unblock();
m_connection = other.m_connection;
m_blocked = other.m_blocked.load(std::memory_order_acquire);
other.m_connection.reset();
other.m_blocked.store(false, std::memory_order_release);
}
return *this;
}
shared_connection_block::~shared_connection_block()
{
unblock();
}
void shared_connection_block::block() noexcept
{
bool blocked = false;
if (m_blocked.compare_exchange_strong(blocked, true, std::memory_order_acq_rel, std::memory_order_relaxed))
{
if (auto connection = m_connection.lock())
{
connection->block();
}
}
}
void shared_connection_block::unblock() noexcept
{
bool blocked = true;
if (m_blocked.compare_exchange_strong(blocked, false, std::memory_order_acq_rel, std::memory_order_relaxed))
{
if (auto connection = m_connection.lock())
{
connection->unblock();
}
}
}
bool shared_connection_block::blocking() const noexcept
{
return m_blocked;
}
void shared_connection_block::increment_if_blocked() const noexcept
{
if (m_blocked)
{
if (auto connection = m_connection.lock())
{
connection->block();
}
}
}
advanced_scoped_connection::advanced_scoped_connection() noexcept = default;
advanced_scoped_connection::advanced_scoped_connection(const advanced_connection& conn) noexcept
: advanced_connection(conn)
{
}
advanced_scoped_connection::advanced_scoped_connection(advanced_connection&& conn) noexcept
: advanced_connection(std::move(conn))
{
}
advanced_scoped_connection::advanced_scoped_connection(advanced_scoped_connection&& other) noexcept = default;
advanced_scoped_connection& advanced_scoped_connection::operator=(advanced_scoped_connection&& other) noexcept = default;
advanced_scoped_connection::~advanced_scoped_connection()
{
disconnect();
}
advanced_connection advanced_scoped_connection::release() noexcept
{
advanced_connection conn = std::move(static_cast<advanced_connection&>(*this));
return conn;
}
} // namespace fastsignals
@@ -0,0 +1,96 @@
#include "../include/fastsignals/function_detail.h"
#include <cstddef>
#include <functional>
namespace fastsignals::detail
{
packed_function::packed_function(packed_function&& other) noexcept
: m_proxy(move_proxy_from(std::move(other)))
{
}
packed_function::packed_function(const packed_function& other)
: m_proxy(clone_proxy_from(other))
{
}
packed_function& packed_function::operator=(packed_function&& other) noexcept
{
assert(this != &other);
reset();
m_proxy = move_proxy_from(std::move(other));
return *this;
}
base_function_proxy* packed_function::move_proxy_from(packed_function&& other) noexcept
{
auto proxy = other.m_proxy ? other.m_proxy->move(&m_buffer) : nullptr;
other.m_proxy = nullptr;
return proxy;
}
base_function_proxy* packed_function::clone_proxy_from(const packed_function& other)
{
return other.m_proxy ? other.m_proxy->clone(&m_buffer) : nullptr;
}
packed_function& packed_function::operator=(const packed_function& other)
{
if (this != &other)
{
if (other.is_buffer_allocated() && is_buffer_allocated())
{
// "This" and "other" are using SBO. Safe assignment must use copy+move
*this = packed_function(other);
}
else
{
// Buffer is used either by "this" or by "other" or not used at all.
// If this uses buffer then other's proxy is null or allocated on heap, so clone won't overwrite buffer
// If this uses heap or null then other's proxy can safely use buffer because reset() won't access buffer
auto newProxy = clone_proxy_from(other);
reset();
m_proxy = newProxy;
}
}
return *this;
}
packed_function::~packed_function() noexcept
{
reset();
}
void packed_function::reset() noexcept
{
if (m_proxy != nullptr)
{
if (is_buffer_allocated())
{
m_proxy->~base_function_proxy();
}
else
{
delete m_proxy;
}
m_proxy = nullptr;
}
}
base_function_proxy& packed_function::unwrap() const
{
if (m_proxy == nullptr)
{
throw std::bad_function_call();
}
return *m_proxy;
}
bool packed_function::is_buffer_allocated() const noexcept
{
return std::less_equal<const void*>()(&m_buffer[0], m_proxy)
&& std::less<const void*>()(m_proxy, &m_buffer[1]);
}
} // namespace fastsignals::detail
@@ -0,0 +1,84 @@
#include "../include/fastsignals/signal_impl.h"
#include <algorithm>
#include <mutex>
namespace fastsignals::detail
{
uint64_t signal_impl::add(packed_function fn)
{
std::lock_guard lock(m_mutex);
m_functions.emplace_back(std::move(fn));
try
{
m_ids.emplace_back(m_nextId);
}
catch (const std::bad_alloc& /*e*/)
{
// Remove function since we failed to add its id
m_functions.pop_back();
throw;
}
return m_nextId++;
}
void signal_impl::remove(uint64_t id) noexcept
{
std::lock_guard lock(m_mutex);
// We use binary search because ids array is always sorted.
auto it = std::lower_bound(m_ids.begin(), m_ids.end(), id);
if (it != m_ids.end() && *it == id)
{
size_t i = std::distance(m_ids.begin(), it);
m_ids.erase(m_ids.begin() + i);
m_functions.erase(m_functions.begin() + i);
}
}
void signal_impl::remove_all() noexcept
{
std::lock_guard lock(m_mutex);
m_functions.clear();
m_ids.clear();
}
bool signal_impl::get_next_slot(packed_function& slot, size_t& expectedIndex, uint64_t& nextId) const
{
// Slots always arranged by ID, so we can use a simple algorithm which avoids races:
// - on each step find first slot with ID >= slotId
// - after each call increment slotId
std::lock_guard lock(m_mutex);
// Avoid binary search if next slot wasn't moved between mutex locks.
if (expectedIndex >= m_ids.size() || m_ids[expectedIndex] != nextId)
{
auto it = (nextId < m_nextId)
? std::lower_bound(m_ids.cbegin(), m_ids.cend(), nextId)
: m_ids.end();
if (it == m_ids.end())
{
return false;
}
expectedIndex = std::distance(m_ids.cbegin(), it);
}
slot.reset();
slot = m_functions[expectedIndex];
nextId = (expectedIndex + 1 < m_ids.size()) ? m_ids[expectedIndex + 1] : m_ids[expectedIndex] + 1;
++expectedIndex;
return true;
}
size_t signal_impl::count() const noexcept
{
std::lock_guard lock(m_mutex);
return m_functions.size();
}
} // namespace fastsignals::detail
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,3 @@
custom_add_test_from_dir(libfastsignals_stress_tests libfastsignals)
target_include_directories(libfastsignals_stress_tests PRIVATE "${CMAKE_SOURCE_DIR}/tests")
@@ -0,0 +1,2 @@
#define CATCH_CONFIG_MAIN
#include "catch2/catch.hpp"
@@ -0,0 +1,124 @@
#include "catch2/catch.hpp"
#include <fastsignals/signal.h>
#include <array>
#include <mutex>
#include <random>
#include <vector>
#include <thread>
using namespace fastsignals;
namespace
{
using string_signal = signal<void(std::string)>;
using string_slot = string_signal::slot_type;
using void_signal = signal<void()>;
using void_slot = void_signal::slot_type;
class named_entity
{
public:
std::string name() const
{
std::lock_guard lock(m_nameMutex);
return m_name;
}
void fire_changed(std::string value)
{
bool fire = false;
{
std::lock_guard lock(m_nameMutex);
if (m_name != value)
{
m_name = std::move(value);
fire = true;
}
}
if (fire)
{
m_nameChanged(value);
}
}
connection on_name_changed(string_slot slot)
{
return m_nameChanged.connect(std::move(slot));
}
private:
mutable std::mutex m_nameMutex;
std::string m_name;
signal<void(std::string)> m_nameChanged;
};
unsigned get_next_seed()
{
static std::minstd_rand seedEngine(777);
return seedEngine();
}
size_t get_random_index(size_t size)
{
thread_local std::minstd_rand disconnectRandomEngine{ get_next_seed() };
std::uniform_int_distribution<size_t> disconnectIndexDistribution{ 0, size - 1 };
return disconnectIndexDistribution(disconnectRandomEngine);
}
} // namespace
TEST_CASE("Can work in a few threads", "[signal]")
{
constexpr unsigned fireThreadCount = 8;
constexpr unsigned signalsCount = 7;
constexpr unsigned fireCountPerThread = 100'000;
constexpr unsigned connectCallsCount = 80'000;
constexpr unsigned totalRunCount = 10;
for (unsigned i = 0; i < totalRunCount; ++i)
{
std::array<void_signal, signalsCount> signals;
std::mutex connectionsMutex;
std::vector<connection> connections;
connections.reserve(connectCallsCount);
std::vector<std::thread> threads;
auto slot = [&] {
std::lock_guard lock(connectionsMutex);
if (!connections.empty())
{
const size_t index = get_random_index(connections.size());
connections.at(index).disconnect();
}
};
threads.emplace_back([&] {
for (unsigned cci = 0; cci < connectCallsCount; ++cci)
{
const size_t index = get_random_index(signalsCount);
connection conn = signals.at(index).connect(slot);
{
std::lock_guard lock(connectionsMutex);
connections.emplace_back(conn);
}
}
});
for (unsigned fti = 0; fti < fireThreadCount; ++fti)
{
threads.emplace_back([&] {
for (unsigned fi = 0; fi < fireCountPerThread; ++fi)
{
const size_t index = get_random_index(signalsCount);
signals.at(index)();
}
});
}
for (auto& thread : threads)
{
thread.join();
}
}
}
@@ -0,0 +1,3 @@
custom_add_test_from_dir(libfastsignals_unit_tests libfastsignals)
target_include_directories(libfastsignals_unit_tests PRIVATE "${CMAKE_SOURCE_DIR}/tests")
@@ -0,0 +1,618 @@
#include "catch2/catch.hpp"
#include <fastsignals/function.h>
#include <array>
using namespace fastsignals;
namespace
{
int Abs(int x)
{
return x >= 0 ? x : -x;
}
int Sum(int a, int b)
{
return a + b;
}
void InplaceAbs(int& x)
{
x = Abs(x);
}
std::string GetStringHello()
{
return "hello";
}
class AbsFunctor
{
public:
int operator()(int x) const
{
return Abs(x);
}
};
class SumFunctor
{
public:
int operator()(int a, int b) const
{
return Sum(a, b);
}
};
class InplaceAbsFunctor
{
public:
void operator()(int& x) /* non-const */
{
if (m_calledOnce)
{
abort();
}
m_calledOnce = true;
InplaceAbs(x);
}
private:
bool m_calledOnce = false;
};
class GetStringFunctor
{
public:
explicit GetStringFunctor(const std::string& value)
: m_value(value)
{
}
std::string operator()() /* non-const */
{
if (m_calledOnce)
{
abort();
}
m_calledOnce = true;
return m_value;
}
private:
bool m_calledOnce = false;
std::string m_value;
};
} // namespace
TEST_CASE("Can use free function with 1 argument", "[function]")
{
function<int(int)> fn = Abs;
REQUIRE(fn(10) == 10);
REQUIRE(fn(-10) == 10);
REQUIRE(fn(0) == 0);
}
TEST_CASE("Can use free function with 2 arguments", "[function]")
{
function<int(int, int)> fn = Sum;
REQUIRE(fn(10, 5) == 15);
REQUIRE(fn(-10, 0) == -10);
}
TEST_CASE("Can use free function without arguments", "[function]")
{
function<std::string()> fn = GetStringHello;
REQUIRE(fn() == "hello");
}
TEST_CASE("Can use free function without return value", "[function]")
{
function<void(int&)> fn = InplaceAbs;
int a = -10;
fn(a);
REQUIRE(a == 10);
}
TEST_CASE("Can use lambda with 1 argument", "[function]")
{
function<int(int)> fn = [](int value) {
return Abs(value);
};
REQUIRE(fn(10) == 10);
REQUIRE(fn(-10) == 10);
REQUIRE(fn(0) == 0);
}
TEST_CASE("Can use lambda with 2 arguments", "[function]")
{
function<int(int, int)> fn = [](auto&& a, auto&& b) {
return Sum(a, b);
};
REQUIRE(fn(10, 5) == 15);
REQUIRE(fn(-10, 0) == -10);
}
TEST_CASE("Can use lambda without arguments", "[function]")
{
function<std::string()> fn = [] {
return GetStringHello();
};
REQUIRE(fn() == "hello");
}
TEST_CASE("Can use lambda without return value", "[function]")
{
bool calledOnce = false;
function<void(int&)> fn = [calledOnce](auto& value) mutable {
if (calledOnce)
{
abort();
}
calledOnce = true;
InplaceAbs(value);
};
int a = -10;
fn(a);
REQUIRE(a == 10);
}
TEST_CASE("Can use functor with 1 argument", "[function]")
{
function<int(int)> fn = AbsFunctor();
REQUIRE(fn(10) == 10);
REQUIRE(fn(-10) == 10);
REQUIRE(fn(0) == 0);
}
TEST_CASE("Can use functor with 2 arguments", "[function]")
{
function<int(int, int)> fn = SumFunctor();
REQUIRE(fn(10, 5) == 15);
REQUIRE(fn(-10, 0) == -10);
}
TEST_CASE("Can use functor without arguments", "[function]")
{
function<std::string()> fn = GetStringFunctor("hello");
REQUIRE(fn() == "hello");
}
TEST_CASE("Can use functor without return value", "[function]")
{
function<void(int&)> fn = InplaceAbsFunctor();
int a = -10;
fn(a);
REQUIRE(a == 10);
}
TEST_CASE("Can construct function with cons std::function<>&", "[function]")
{
using BoolCallback = std::function<void(bool succeed)>;
bool value = false;
const BoolCallback& cb = [&value](bool succeed) {
value = succeed;
};
function<void(bool)> fn = cb;
fn(true);
REQUIRE(value == true);
fn(false);
REQUIRE(value == false);
fn(true);
REQUIRE(value == true);
}
TEST_CASE("Can copy function", "[function]")
{
unsigned calledCount = 0;
bool value = false;
function<void(bool)> callback = [&](bool gotValue) {
++calledCount;
value = gotValue;
};
auto callback2 = callback;
REQUIRE(calledCount == 0);
CHECK(!value);
callback(true);
REQUIRE(calledCount == 1);
CHECK(value);
callback2(false);
REQUIRE(calledCount == 2);
CHECK(!value);
}
TEST_CASE("Can move function", "[function]")
{
bool called = false;
function<void()> callback = [&] {
called = true;
};
auto callback2(std::move(callback));
REQUIRE_THROWS(callback());
REQUIRE(!called);
callback2();
REQUIRE(called);
}
TEST_CASE("Works when copying self", "[function]")
{
bool called = false;
function<void()> callback = [&] {
called = true;
};
callback = callback;
callback();
REQUIRE(called);
}
TEST_CASE("Can release packed function", "[function]")
{
function<int()> iota = [v = 0]() mutable {
return v++;
};
REQUIRE(iota() == 0);
auto packedFn = std::move(iota).release();
REQUIRE_THROWS_AS(iota(), std::bad_function_call);
auto&& proxy = packedFn.get<int()>();
REQUIRE(proxy() == 1);
REQUIRE(proxy() == 2);
}
TEST_CASE("Function copy has its own packed function", "[function]")
{
function<int()> iota = [v = 0]() mutable {
return v++;
};
REQUIRE(iota() == 0);
auto iotaCopy(iota);
REQUIRE(iota() == 1);
REQUIRE(iota() == 2);
REQUIRE(iotaCopy() == 1);
REQUIRE(iotaCopy() == 2);
}
TEST_CASE("can work with callables that have vtable", "[function]")
{
class Base
{
};
class Interface : public Base
{
public:
virtual ~Interface() = default;
virtual void operator()() const = 0;
};
class Class : public Interface
{
public:
Class(bool* destructorCalled)
: m_destructorCalled(destructorCalled)
{
}
~Class()
{
*m_destructorCalled = true;
}
void operator()() const override
{
}
bool* m_destructorCalled = nullptr;
};
bool destructorCalled = false;
{
function<void()> f = Class(&destructorCalled);
f();
auto packed = f.release();
destructorCalled = false;
}
CHECK(destructorCalled);
}
TEST_CASE("can work with callables with virtual inheritance", "[function]")
{
struct A
{
void operator()() const
{
m_called = true;
}
~A()
{
*m_destructorCalled = true;
}
mutable bool m_called = false;
bool* m_destructorCalled = nullptr;
};
struct B : public virtual A
{
};
struct C : public virtual A
{
};
struct D : virtual public B
, virtual public C
{
D(bool* destructorCalled)
{
m_destructorCalled = destructorCalled;
}
using A::operator();
};
bool destructorCalled = false;
{
function<void()> f = D(&destructorCalled);
f();
auto packed = f.release();
destructorCalled = false;
}
CHECK(destructorCalled);
}
TEST_CASE("uses copy constructor if callable's move constructor throws", "[function]")
{
struct Callable
{
Callable() = default;
Callable(Callable&&)
{
throw std::runtime_error("throw");
}
Callable(const Callable& other) = default;
void operator()() const
{
}
};
Callable c;
function<void()> f(c);
auto f2 = std::move(f);
f2();
CHECK_THROWS(f());
}
TEST_CASE("uses move constructor if it is noexcept", "[function]")
{
struct Callable
{
Callable() = default;
Callable(Callable&& other) noexcept = default;
Callable(const Callable&)
{
throw std::runtime_error("throw");
}
void operator()() const
{
}
};
Callable c;
function<void()> f(std::move(c));
auto f2 = std::move(f);
f2();
CHECK_THROWS(f());
}
TEST_CASE("can copy and move empty function", "[function]")
{
function<void()> f;
auto f2 = f;
auto f3 = std::move(f);
}
TEST_CASE("properly copies callable on assignment", "[function]")
{
struct Callable
{
Callable(int& aliveCounter)
: m_aliveCounter(&aliveCounter)
{
++*m_aliveCounter;
}
Callable(const Callable& other)
: m_aliveCounter(other.m_aliveCounter)
{
if (m_aliveCounter)
{
++*m_aliveCounter;
}
}
Callable(Callable&& other) noexcept
: m_aliveCounter(other.m_aliveCounter)
{
other.m_aliveCounter = nullptr;
}
~Callable()
{
if (m_aliveCounter)
{
--*m_aliveCounter;
}
}
void operator()() const
{
}
int* m_aliveCounter = nullptr;
};
int aliveCounter1 = 0;
int aliveCounter2 = 0;
function<void()> f = Callable(aliveCounter1);
function<void()> f2 = Callable(aliveCounter2);
CHECK(aliveCounter1 == 1);
CHECK(aliveCounter2 == 1);
f = f2;
CHECK(aliveCounter1 == 0);
CHECK(aliveCounter2 == 2);
f = function<void()>();
f2 = function<void()>();
CHECK(aliveCounter1 == 0);
CHECK(aliveCounter2 == 0);
}
TEST_CASE("copy assignment operator provides strong exception safety", "[function]")
{
struct State
{
int callCount = 0;
bool throwOnCopy = false;
};
struct Callable
{
Callable(State& state)
: state(&state)
{
}
void operator()()
{
++state->callCount;
}
Callable(const Callable& other)
: state(other.state)
{
if (state->throwOnCopy)
{
throw std::runtime_error("throw on request");
}
}
State* state = nullptr;
};
static_assert(!detail::can_use_inplace_buffer<Callable>);
State srcState;
State dstState;
function<void()> srcFn(Callable{ srcState });
function<void()> dstFn(Callable{ dstState });
srcFn();
dstFn();
REQUIRE(srcState.callCount == 1);
REQUIRE(dstState.callCount == 1);
srcState.throwOnCopy = true;
REQUIRE_THROWS_AS(dstFn = srcFn, std::runtime_error);
// srcFn and dstFn must not be emptied even if assignment throws
REQUIRE_NOTHROW(srcFn());
REQUIRE_NOTHROW(dstFn());
// srcFn and dstFn must keep their state
REQUIRE(srcState.callCount == 2);
REQUIRE(dstState.callCount == 2);
// The next copy will succeed
srcState.throwOnCopy = false;
REQUIRE_NOTHROW(dstFn = srcFn);
// Both functions are usable
REQUIRE_NOTHROW(srcFn());
REQUIRE_NOTHROW(dstFn());
// After assignment, dstFn and srcFn refer the same state - srcState
REQUIRE(srcState.callCount == 4);
REQUIRE(dstState.callCount == 2);
}
TEST_CASE("assignment of variously allocated functions", "[function]")
{
int heapCalls = 0;
auto onHeap = [&heapCalls, largeVar = std::array<std::string, 1000>()]() mutable {
std::fill(largeVar.begin(), largeVar.end(), "large string to be allocated on heap instead of stack");
++heapCalls;
};
int stackCalls = 0;
auto onStack = [&stackCalls] {
++stackCalls;
};
static_assert(detail::can_use_inplace_buffer<detail::function_proxy_impl<decltype(onStack), void>>);
static_assert(!detail::can_use_inplace_buffer<detail::function_proxy_impl<decltype(onHeap), void>>);
using Fn = function<void()>;
{
Fn heap(onHeap);
Fn stack(onStack);
heap = stack;
heap();
REQUIRE(stackCalls == 1);
REQUIRE(heapCalls == 0);
}
{
Fn heap(onHeap);
Fn stack(onStack);
stack = heap;
stack();
REQUIRE(stackCalls == 1);
REQUIRE(heapCalls == 1);
}
{
Fn heap(onHeap);
Fn heap1(onHeap);
heap = heap1;
heap();
REQUIRE(stackCalls == 1);
REQUIRE(heapCalls == 2);
}
{
Fn stack(onStack);
Fn stack1(onStack);
stack = stack1;
stack();
REQUIRE(stackCalls == 2);
REQUIRE(heapCalls == 2);
}
{
Fn heap(onHeap);
Fn empty;
heap = empty;
REQUIRE_THROWS(heap());
REQUIRE(stackCalls == 2);
REQUIRE(heapCalls == 2);
}
{
Fn stack(onStack);
Fn empty;
stack = empty;
REQUIRE_THROWS(stack());
REQUIRE(stackCalls == 2);
REQUIRE(heapCalls == 2);
}
{
Fn empty;
Fn heap(onHeap);
empty = heap;
empty();
REQUIRE(stackCalls == 2);
REQUIRE(heapCalls == 3);
}
{
Fn empty;
Fn stack(onStack);
empty = stack;
empty();
REQUIRE(stackCalls == 3);
REQUIRE(heapCalls == 3);
}
{
Fn empty;
Fn empty1;
empty = empty1;
REQUIRE_THROWS(empty());
REQUIRE(stackCalls == 3);
REQUIRE(heapCalls == 3);
}
}
@@ -0,0 +1,132 @@
#include "catch2/catch.hpp"
#include <fastsignals/bind_weak.h>
using namespace fastsignals;
namespace
{
class Testbed
{
public:
Testbed(unsigned& counter)
: m_pCounter(&counter)
{
}
void IncrementNonConst()
{
++(*m_pCounter);
}
void IncrementsConst() const
{
++(*m_pCounter);
}
int ReflectInt(int value) const
{
return value;
}
private:
unsigned* m_pCounter = nullptr;
};
} // namespace
TEST_CASE("can bind const methods", "[bind_weak]")
{
unsigned counter = 0;
auto pSharedBed = std::make_shared<Testbed>(counter);
auto boundFn = bind_weak(&Testbed::IncrementNonConst, pSharedBed);
REQUIRE(counter == 0u);
boundFn();
REQUIRE(counter == 1u);
boundFn();
REQUIRE(counter == 2u);
pSharedBed = nullptr;
boundFn();
REQUIRE(counter == 2u);
boundFn();
REQUIRE(counter == 2u);
}
TEST_CASE("can bind non const methods", "[bind_weak]")
{
unsigned counter = 0;
auto pSharedBed = std::make_shared<Testbed>(counter);
auto boundFn = bind_weak(&Testbed::IncrementsConst, pSharedBed);
REQUIRE(counter == 0u);
boundFn();
REQUIRE(counter == 1u);
boundFn();
REQUIRE(counter == 2u);
pSharedBed = nullptr;
boundFn();
REQUIRE(counter == 2u);
boundFn();
REQUIRE(counter == 2u);
}
TEST_CASE("can bind method with argument value", "[bind_weak]")
{
unsigned counter = 0;
auto pSharedBed = std::make_shared<Testbed>(counter);
auto boundFn = bind_weak(&Testbed::ReflectInt, pSharedBed, 42);
REQUIRE(boundFn() == 42);
REQUIRE(boundFn() == 42);
pSharedBed = nullptr;
REQUIRE(boundFn() == 0);
REQUIRE(boundFn() == 0);
}
TEST_CASE("copies value when bind method with argument const reference value", "[bind_weak]")
{
unsigned counter = 0;
auto pSharedBed = std::make_shared<Testbed>(counter);
auto makeBoundFn = [&]() {
int value = 15;
const int& valueRef = value;
auto result = bind_weak(&Testbed::ReflectInt, pSharedBed, valueRef);
value = 25;
return result;
};
auto boundFn = makeBoundFn();
REQUIRE(boundFn(42) == 15);
REQUIRE(boundFn(42) == 15);
pSharedBed = nullptr;
REQUIRE(boundFn(42) == 0);
REQUIRE(boundFn(42) == 0);
}
TEST_CASE("copies value when bind method with argument reference value", "[bind_weak]")
{
unsigned counter = 0;
auto pSharedBed = std::make_shared<Testbed>(counter);
auto makeBoundFn = [&]() {
int value = 15;
int& valueRef = value;
auto result = bind_weak(&Testbed::ReflectInt, pSharedBed, valueRef);
valueRef = 25;
return result;
};
auto boundFn = makeBoundFn();
REQUIRE(boundFn(42) == 15);
REQUIRE(boundFn(42) == 15);
pSharedBed = nullptr;
REQUIRE(boundFn(42) == 0);
REQUIRE(boundFn(42) == 0);
}
TEST_CASE("can bind method with placeholder", "[bind_weak]")
{
unsigned counter = 0;
auto pSharedBed = std::make_shared<Testbed>(counter);
auto boundFn = bind_weak(&Testbed::ReflectInt, pSharedBed, std::placeholders::_1);
REQUIRE(boundFn(42) == 42);
REQUIRE(boundFn(42) == 42);
pSharedBed = nullptr;
REQUIRE(boundFn(42) == 0);
REQUIRE(boundFn(42) == 0);
}
@@ -0,0 +1,2 @@
#define CATCH_CONFIG_MAIN
#include "catch2/catch.hpp"
@@ -0,0 +1,707 @@
#include "catch2/catch.hpp"
#include <fastsignals/signal.h>
#include <string>
using namespace fastsignals;
using namespace std::literals;
namespace
{
template <class T>
class any_of_combiner
{
public:
static_assert(std::is_same_v<T, bool>);
using result_type = bool;
template <class TRef>
void operator()(TRef&& value)
{
m_result = m_result || bool(value);
}
result_type get_value() const
{
return m_result;
}
private:
result_type m_result = {};
};
} // namespace
TEST_CASE("Can connect a few slots and emit", "[signal]")
{
signal<void(int)> valueChanged;
int value1 = 0;
int value2 = 0;
valueChanged.connect([&value1](int value) {
value1 = value;
});
valueChanged.connect([&value2](int value) {
value2 = value;
});
REQUIRE(value1 == 0);
REQUIRE(value2 == 0);
valueChanged(10);
REQUIRE(value1 == 10);
REQUIRE(value2 == 10);
}
TEST_CASE("Can safely pass rvalues", "[signal]")
{
const std::string expected = "If the type T is a reference type, provides the member typedef type which is the type referred to by T. Otherwise type is T.";
std::string passedValue = expected;
signal<void(std::string)> valueChanged;
std::string value1;
std::string value2;
valueChanged.connect([&value1](std::string value) {
value1 = value;
});
valueChanged.connect([&value2](std::string value) {
value2 = value;
});
valueChanged(std::move(passedValue));
REQUIRE(value1 == expected);
REQUIRE(value2 == expected);
}
TEST_CASE("Can pass mutable ref", "[signal]")
{
const std::string expected = "If the type T is a reference type, provides the member typedef type which is the type referred to by T. Otherwise type is T.";
signal<void(std::string&)> valueChanged;
std::string passedValue;
valueChanged.connect([expected](std::string& value) {
value = expected;
});
valueChanged(passedValue);
REQUIRE(passedValue == expected);
}
TEST_CASE("Can disconnect slot with explicit call", "[signal]")
{
signal<void(int)> valueChanged;
int value1 = 0;
int value2 = 0;
int value3 = 0;
auto conn1 = valueChanged.connect([&value1](int value) {
value1 = value;
});
auto conn2 = valueChanged.connect([&value2](int value) {
value2 = value;
});
valueChanged.connect([&value3](int value) {
value3 = value;
});
REQUIRE(value1 == 0);
REQUIRE(value2 == 0);
REQUIRE(value3 == 0);
valueChanged(10);
REQUIRE(value1 == 10);
REQUIRE(value2 == 10);
REQUIRE(value3 == 10);
conn2.disconnect();
valueChanged(-99);
REQUIRE(value1 == -99);
REQUIRE(value2 == 10);
REQUIRE(value3 == -99);
conn1.disconnect();
valueChanged(17);
REQUIRE(value1 == -99);
REQUIRE(value2 == 10);
REQUIRE(value3 == 17);
}
TEST_CASE("Can disconnect slot with scoped_connection", "[signal]")
{
signal<void(int)> valueChanged;
int value1 = 0;
int value2 = 0;
int value3 = 0;
{
scoped_connection conn1 = valueChanged.connect([&value1](int value) {
value1 = value;
});
{
scoped_connection conn2 = valueChanged.connect([&value2](int value) {
value2 = value;
});
valueChanged.connect([&value3](int value) {
value3 = value;
});
REQUIRE(value1 == 0);
REQUIRE(value2 == 0);
REQUIRE(value3 == 0);
valueChanged(10);
REQUIRE(value1 == 10);
REQUIRE(value2 == 10);
REQUIRE(value3 == 10);
}
// conn2 disconnected.
valueChanged(-99);
REQUIRE(value1 == -99);
REQUIRE(value2 == 10);
REQUIRE(value3 == -99);
}
// conn1 disconnected.
valueChanged(17);
REQUIRE(value1 == -99);
REQUIRE(value2 == 10);
REQUIRE(value3 == 17);
}
TEST_CASE("Can disconnect all", "[signal]")
{
signal<void(int)> valueChanged;
int value1 = 0;
int value2 = 0;
int value3 = 0;
valueChanged.connect([&value1](int value) {
value1 = value;
});
valueChanged.connect([&value2](int value) {
value2 = value;
});
valueChanged.connect([&value3](int value) {
value3 = value;
});
REQUIRE(value1 == 0);
REQUIRE(value2 == 0);
REQUIRE(value3 == 0);
valueChanged(63);
REQUIRE(value1 == 63);
REQUIRE(value2 == 63);
REQUIRE(value3 == 63);
valueChanged.disconnect_all_slots();
valueChanged(101);
REQUIRE(value1 == 63);
REQUIRE(value2 == 63);
REQUIRE(value3 == 63);
}
TEST_CASE("Can disconnect inside slot", "[signal]")
{
signal<void(int)> valueChanged;
int value1 = 0;
int value2 = 0;
int value3 = 0;
connection conn2;
valueChanged.connect([&value1](int value) {
value1 = value;
});
conn2 = valueChanged.connect([&](int value) {
value2 = value;
conn2.disconnect();
});
valueChanged.connect([&value3](int value) {
value3 = value;
});
REQUIRE(value1 == 0);
REQUIRE(value2 == 0);
REQUIRE(value3 == 0);
valueChanged(63);
REQUIRE(value1 == 63);
REQUIRE(value2 == 63);
REQUIRE(value3 == 63);
valueChanged(101);
REQUIRE(value1 == 101);
REQUIRE(value2 == 63); // disconnected in slot.
REQUIRE(value3 == 101);
}
TEST_CASE("Disconnects OK if signal dead first", "[signal]")
{
connection conn2;
{
scoped_connection conn1;
{
signal<void(int)> valueChanged;
conn2 = valueChanged.connect([](int) {
});
// Just unused.
valueChanged.connect([](int) {
});
conn1 = valueChanged.connect([](int) {
});
}
REQUIRE(conn2.connected());
REQUIRE(conn1.connected());
conn2.disconnect();
REQUIRE(!conn2.connected());
REQUIRE(conn1.connected());
}
conn2.disconnect();
}
TEST_CASE("Returns last called slot result with default combiner", "[signal]")
{
connection conn2;
{
scoped_connection conn1;
{
signal<int(int)> absSignal;
conn2 = absSignal.connect([](int value) {
return value * value;
});
conn1 = absSignal.connect([](int value) {
return abs(value);
});
absSignal(-1);
REQUIRE(absSignal(45) == 45);
REQUIRE(absSignal(-1) == 1);
REQUIRE(absSignal(-177) == 177);
REQUIRE(absSignal(0) == 0);
}
REQUIRE(conn2.connected());
conn2.disconnect();
REQUIRE(!conn2.connected());
}
conn2.disconnect();
REQUIRE(!conn2.connected());
}
TEST_CASE("Works with custom any_of combiner", "[signal]")
{
using cancellable_signal = signal<bool(std::string), any_of_combiner>;
cancellable_signal startRequested;
auto conn1 = startRequested.connect([](std::string op) {
return op == "1";
});
auto conn2 = startRequested.connect([](std::string op) {
return op == "1" || op == "2";
});
REQUIRE(startRequested("0") == false);
REQUIRE(startRequested("1") == true);
REQUIRE(startRequested("2") == true);
REQUIRE(startRequested("3") == false);
conn1.disconnect();
conn2.disconnect();
REQUIRE(startRequested("0") == false);
REQUIRE(startRequested("1") == false);
REQUIRE(startRequested("2") == false);
REQUIRE(startRequested("3") == false);
}
TEST_CASE("Can release scoped connection", "[signal]")
{
int value2 = 0;
int value3 = 0;
signal<void(int)> valueChanged;
connection conn1;
{
scoped_connection conn2;
scoped_connection conn3;
conn2 = valueChanged.connect([&value2](int x) {
value2 = x;
});
conn3 = valueChanged.connect([&value3](int x) {
value3 = x;
});
valueChanged(42);
REQUIRE(value2 == 42);
REQUIRE(value3 == 42);
REQUIRE(conn2.connected());
REQUIRE(conn3.connected());
REQUIRE(!conn1.connected());
conn1 = conn3.release();
REQUIRE(conn2.connected());
REQUIRE(!conn3.connected());
REQUIRE(conn1.connected());
valueChanged(144);
REQUIRE(value2 == 144);
REQUIRE(value3 == 144);
}
// conn2 disconnected, conn1 connected.
valueChanged(17);
REQUIRE(value2 == 144);
REQUIRE(value3 == 17);
REQUIRE(conn1.connected());
conn1.disconnect();
valueChanged(90);
REQUIRE(value2 == 144);
REQUIRE(value3 == 17);
}
TEST_CASE("Can use signal with more than one argument", "[signal]")
{
signal<void(int, std::string, std::vector<std::string>)> event;
int value1 = 0;
std::string value2;
std::vector<std::string> value3;
event.connect([&](int v1, const std::string& v2, const std::vector<std::string>& v3) {
value1 = v1;
value2 = v2;
value3 = v3;
});
event(9815, "using namespace std::literals!"s, std::vector{ "std::vector"s, "using namespace std::literals"s });
REQUIRE(value1 == 9815);
REQUIRE(value2 == "using namespace std::literals!"s);
REQUIRE(value3 == std::vector{ "std::vector"s, "using namespace std::literals"s });
}
TEST_CASE("Can blocks slots using shared_connection_block", "[signal]")
{
bool callbackShouldBeCalled = true;
bool callbackCalled = false;
const int value = 123;
signal<void(int)> event;
auto conn = event.connect([&](int gotValue) {
CHECK(gotValue == value);
callbackCalled = true;
if (!callbackShouldBeCalled)
{
FAIL("callback is blocked and should not be called");
}
},
advanced_tag{});
event(value);
REQUIRE(callbackCalled);
shared_connection_block block(conn);
callbackShouldBeCalled = false;
callbackCalled = false;
event(value);
REQUIRE(!callbackCalled);
block.unblock();
callbackShouldBeCalled = true;
event(value);
REQUIRE(callbackCalled);
}
TEST_CASE("Other slots are unaffected by the block", "[signal]")
{
bool callback1Called = false;
bool callback2Called = false;
const int value = 123;
signal<void(int)> event;
auto conn1 = event.connect([&](int gotValue) {
CHECK(gotValue == value);
callback1Called = true;
},
advanced_tag{});
auto conn2 = event.connect([&](int) {
callback2Called = true;
FAIL("callback is blocked and should not be called");
},
advanced_tag{});
shared_connection_block block(conn2);
event(value);
REQUIRE(callback1Called);
REQUIRE(!callback2Called);
}
TEST_CASE("Multiple blocks block until last one is unblocked", "[signal]")
{
bool callbackShouldBeCalled = false;
bool callbackCalled = false;
const int value = 123;
signal<void(int)> event;
auto conn = event.connect([&](int gotValue) {
CHECK(gotValue == value);
callbackCalled = true;
if (!callbackShouldBeCalled)
{
FAIL("callback is blocked and should not be called");
}
},
advanced_tag{});
shared_connection_block block1(conn);
shared_connection_block block2(conn);
event(value);
REQUIRE(!callbackCalled);
block1.unblock();
event(value);
REQUIRE(!callbackCalled);
block1.block();
block2.unblock();
event(value);
REQUIRE(!callbackCalled);
block1.unblock();
callbackShouldBeCalled = true;
event(value);
REQUIRE(callbackCalled);
}
TEST_CASE("Can copy and move shared_connection_block objects", "[signal]")
{
bool callbackShouldBeCalled = false;
bool callbackCalled = false;
const int value = 123;
signal<void(int)> event;
auto conn = event.connect([&](int gotValue) {
CHECK(gotValue == value);
callbackCalled = true;
if (!callbackShouldBeCalled)
{
FAIL("callback is blocked and should not be called");
}
},
advanced_tag{});
shared_connection_block block1(conn);
shared_connection_block block2(block1);
event(value);
REQUIRE(block1.blocking());
REQUIRE(block2.blocking());
REQUIRE(!callbackCalled);
shared_connection_block block3(std::move(block2));
event(value);
REQUIRE(block1.blocking());
REQUIRE(!block2.blocking());
REQUIRE(block3.blocking());
REQUIRE(!callbackCalled);
block2 = block3;
event(value);
REQUIRE(block1.blocking());
REQUIRE(block2.blocking());
REQUIRE(block3.blocking());
REQUIRE(!callbackCalled);
block3 = std::move(block2);
event(value);
REQUIRE(block1.blocking());
REQUIRE(!block2.blocking());
REQUIRE(block3.blocking());
REQUIRE(!callbackCalled);
block3 = shared_connection_block(conn, false);
event(value);
REQUIRE(block1.blocking());
REQUIRE(!block2.blocking());
REQUIRE(!block3.blocking());
REQUIRE(!callbackCalled);
block1.unblock();
callbackShouldBeCalled = true;
event(value);
REQUIRE(!block1.blocking());
REQUIRE(!block2.blocking());
REQUIRE(!block3.blocking());
REQUIRE(callbackCalled);
}
TEST_CASE("Unblocks when shared_connection_block goes out of scope")
{
bool callbackCalled = false;
const int value = 123;
signal<void(int)> event;
auto conn = event.connect([&](int gotValue) {
CHECK(gotValue == value);
callbackCalled = true;
},
advanced_tag{});
callbackCalled = false;
event(value);
CHECK(callbackCalled);
{
callbackCalled = false;
shared_connection_block block(conn);
event(value);
CHECK(!callbackCalled);
{
callbackCalled = false;
shared_connection_block block2(conn);
event(value);
CHECK(!callbackCalled);
}
}
callbackCalled = false;
event(value);
CHECK(callbackCalled);
}
TEST_CASE("Can disconnect advanced slot using advanced_scoped_connection", "[signal]")
{
signal<void(int)> valueChanged;
int value1 = 0;
int value2 = 0;
int value3 = 0;
{
advanced_scoped_connection conn1 = valueChanged.connect([&value1](int value) {
value1 = value;
},
advanced_tag{});
{
advanced_scoped_connection conn2 = valueChanged.connect([&value2](int value) {
value2 = value;
},
advanced_tag{});
valueChanged.connect([&value3](int value) {
value3 = value;
});
REQUIRE(value1 == 0);
REQUIRE(value2 == 0);
REQUIRE(value3 == 0);
valueChanged(10);
REQUIRE(value1 == 10);
REQUIRE(value2 == 10);
REQUIRE(value3 == 10);
}
// conn2 disconnected.
valueChanged(-99);
REQUIRE(value1 == -99);
REQUIRE(value2 == 10);
REQUIRE(value3 == -99);
}
// conn1 disconnected.
valueChanged(17);
REQUIRE(value1 == -99);
REQUIRE(value2 == 10);
REQUIRE(value3 == 17);
}
TEST_CASE("Can move signal", "[signal]")
{
signal<void()> src;
int srcFireCount = 0;
auto srcConn = src.connect([&srcFireCount] {
++srcFireCount;
});
src();
REQUIRE(srcFireCount == 1);
auto dst = std::move(src);
int dstFireCount = 0;
auto dstConn = dst.connect([&dstFireCount] {
++dstFireCount;
});
dst();
REQUIRE(srcFireCount == 2);
REQUIRE(dstFireCount == 1);
srcConn.disconnect();
dstConn.disconnect();
dst();
REQUIRE(srcFireCount == 2);
REQUIRE(dstFireCount == 1);
}
TEST_CASE("Can swap signals", "[signal]")
{
signal<void()> s1;
signal<void()> s2;
int s1FireCount = 0;
int s2FireCount = 0;
s1.connect([&s1FireCount] {
++s1FireCount;
});
s2.connect([&s2FireCount] {
++s2FireCount;
});
std::swap(s1, s2);
s1();
REQUIRE(s1FireCount == 0);
REQUIRE(s2FireCount == 1);
s2();
REQUIRE(s1FireCount == 1);
REQUIRE(s2FireCount == 1);
}
TEST_CASE("Signal can be destroyed inside its slot and will call the rest of its slots", "[signal]")
{
std::optional<signal<void()>> s;
s.emplace();
s->connect([&] {
s.reset();
});
bool called = false;
s->connect([&] {
called = true;
});
(*s)();
CHECK(called);
}
TEST_CASE("Signal can be used as a slot for another signal", "[signal]")
{
signal<void()> s1;
bool called = false;
s1.connect([&] {
called = true;
});
signal<void()> s2;
s2.connect(s1);
s2();
CHECK(called);
}
// memory leak fix
TEST_CASE("Releases lambda and its captured const data", "[signal]")
{
struct Captured
{
Captured(bool& released)
: m_released(released)
{
}
~Captured()
{
m_released = true;
}
private:
bool& m_released;
};
bool released = false;
{
const auto captured = std::make_shared<Captured>(released);
signal<void()> changeSignal;
changeSignal.connect([captured]{});
}
CHECK(released);
}
+2
View File
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/***************************************************************************
* Copyright (c) 2008 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
+2
View File
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/***************************************************************************
* Copyright (c) 2008 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
+4 -2
View File
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/***************************************************************************
* Copyright (c) 2002 Jürgen Riegel <juergen.riegel@web.de> *
* *
@@ -649,8 +651,8 @@ struct DocTiming {
class DocOpenGuard {
public:
bool &flag;
boost::signals2::signal<void ()> &signal;
DocOpenGuard(bool &f, boost::signals2::signal<void ()> &s)
fastsignals::signal<void ()> &signal;
DocOpenGuard(bool &f, fastsignals::signal<void ()> &s)
:flag(f),signal(s)
{
flag = true;
+47 -44
View File
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/***************************************************************************
* Copyright (c) 2002 Jürgen Riegel <juergen.riegel@web.de> *
* *
@@ -24,10 +26,11 @@
#ifndef SRC_APP_APPLICATION_H_
#define SRC_APP_APPLICATION_H_
#include <boost/signals2.hpp>
#include <fastsignals/signal.h>
#include <QtCore/qtextstream.h>
#include <deque>
#include <list>
#include <vector>
#include <list>
#include <set>
@@ -220,49 +223,49 @@ public:
/** @name Signals of the Application */
//@{
/// signal on new Document
boost::signals2::signal<void (const Document&, bool)> signalNewDocument;
fastsignals::signal<void (const Document&, bool)> signalNewDocument;
/// signal on document getting deleted
boost::signals2::signal<void (const Document&)> signalDeleteDocument;
fastsignals::signal<void (const Document&)> signalDeleteDocument;
/// signal on already deleted Document
boost::signals2::signal<void ()> signalDeletedDocument;
fastsignals::signal<void ()> signalDeletedDocument;
/// signal on relabeling Document (user name)
boost::signals2::signal<void (const Document&)> signalRelabelDocument;
fastsignals::signal<void (const Document&)> signalRelabelDocument;
/// signal on renaming Document (internal name)
boost::signals2::signal<void (const Document&)> signalRenameDocument;
fastsignals::signal<void (const Document&)> signalRenameDocument;
/// signal on activating Document
boost::signals2::signal<void (const Document&)> signalActiveDocument;
fastsignals::signal<void (const Document&)> signalActiveDocument;
/// signal on saving Document
boost::signals2::signal<void (const Document&)> signalSaveDocument;
fastsignals::signal<void (const Document&)> signalSaveDocument;
/// signal on starting to restore Document
boost::signals2::signal<void (const Document&)> signalStartRestoreDocument;
fastsignals::signal<void (const Document&)> signalStartRestoreDocument;
/// signal on restoring Document
boost::signals2::signal<void (const Document&)> signalFinishRestoreDocument;
fastsignals::signal<void (const Document&)> signalFinishRestoreDocument;
/// signal on pending reloading of a partial Document
boost::signals2::signal<void (const Document&)> signalPendingReloadDocument;
fastsignals::signal<void (const Document&)> signalPendingReloadDocument;
/// signal on starting to save Document
boost::signals2::signal<void (const Document&, const std::string&)> signalStartSaveDocument;
fastsignals::signal<void (const Document&, const std::string&)> signalStartSaveDocument;
/// signal on saved Document
boost::signals2::signal<void (const Document&, const std::string&)> signalFinishSaveDocument;
fastsignals::signal<void (const Document&, const std::string&)> signalFinishSaveDocument;
/// signal on undo in document
boost::signals2::signal<void (const Document&)> signalUndoDocument;
fastsignals::signal<void (const Document&)> signalUndoDocument;
/// signal on application wide undo
boost::signals2::signal<void ()> signalUndo;
fastsignals::signal<void ()> signalUndo;
/// signal on redo in document
boost::signals2::signal<void (const Document&)> signalRedoDocument;
fastsignals::signal<void (const Document&)> signalRedoDocument;
/// signal on application wide redo
boost::signals2::signal<void ()> signalRedo;
fastsignals::signal<void ()> signalRedo;
/// signal before open active transaction
boost::signals2::signal<void (const std::string&)> signalBeforeOpenTransaction;
fastsignals::signal<void (const std::string&)> signalBeforeOpenTransaction;
/// signal before close/abort active transaction
boost::signals2::signal<void (bool)> signalBeforeCloseTransaction;
fastsignals::signal<void (bool)> signalBeforeCloseTransaction;
/// signal after close/abort active transaction
boost::signals2::signal<void (bool)> signalCloseTransaction;
fastsignals::signal<void (bool)> signalCloseTransaction;
/// signal on show hidden items
boost::signals2::signal<void (const Document&)> signalShowHidden;
fastsignals::signal<void (const Document&)> signalShowHidden;
/// signal on start opening document(s)
boost::signals2::signal<void ()> signalStartOpenDocument;
fastsignals::signal<void ()> signalStartOpenDocument;
/// signal on finished opening document(s)
boost::signals2::signal<void ()> signalFinishOpenDocument;
fastsignals::signal<void ()> signalFinishOpenDocument;
//@}
@@ -272,34 +275,34 @@ public:
*/
//@{
/// signal before change of doc property
boost::signals2::signal<void (const App::Document&, const App::Property&)> signalBeforeChangeDocument;
fastsignals::signal<void (const App::Document&, const App::Property&)> signalBeforeChangeDocument;
/// signal on changed doc property
boost::signals2::signal<void (const App::Document&, const App::Property&)> signalChangedDocument;
fastsignals::signal<void (const App::Document&, const App::Property&)> signalChangedDocument;
/// signal on new Object
boost::signals2::signal<void (const App::DocumentObject&)> signalNewObject;
//boost::signals2::signal<void (const App::DocumentObject&)> m_sig;
fastsignals::signal<void (const App::DocumentObject&)> signalNewObject;
//fastsignals::signal<void (const App::DocumentObject&)> m_sig;
/// signal on deleted Object
boost::signals2::signal<void (const App::DocumentObject&)> signalDeletedObject;
fastsignals::signal<void (const App::DocumentObject&)> signalDeletedObject;
/// signal on changed Object
boost::signals2::signal<void (const App::DocumentObject&, const App::Property&)> signalBeforeChangeObject;
fastsignals::signal<void (const App::DocumentObject&, const App::Property&)> signalBeforeChangeObject;
/// signal on changed Object
boost::signals2::signal<void (const App::DocumentObject&, const App::Property&)> signalChangedObject;
fastsignals::signal<void (const App::DocumentObject&, const App::Property&)> signalChangedObject;
/// signal on relabeled Object
boost::signals2::signal<void (const App::DocumentObject&)> signalRelabelObject;
fastsignals::signal<void (const App::DocumentObject&)> signalRelabelObject;
/// signal on activated Object
boost::signals2::signal<void (const App::DocumentObject&)> signalActivatedObject;
fastsignals::signal<void (const App::DocumentObject&)> signalActivatedObject;
/// signal before recomputed document
boost::signals2::signal<void (const App::Document&)> signalBeforeRecomputeDocument;
fastsignals::signal<void (const App::Document&)> signalBeforeRecomputeDocument;
/// signal on recomputed document
boost::signals2::signal<void (const App::Document&)> signalRecomputed;
fastsignals::signal<void (const App::Document&)> signalRecomputed;
/// signal on recomputed document object
boost::signals2::signal<void (const App::DocumentObject&)> signalObjectRecomputed;
fastsignals::signal<void (const App::DocumentObject&)> signalObjectRecomputed;
// signal on opened transaction
boost::signals2::signal<void (const App::Document&, std::string)> signalOpenTransaction;
fastsignals::signal<void (const App::Document&, std::string)> signalOpenTransaction;
// signal a committed transaction
boost::signals2::signal<void (const App::Document&)> signalCommitTransaction;
fastsignals::signal<void (const App::Document&)> signalCommitTransaction;
// signal an aborted transaction
boost::signals2::signal<void (const App::Document&)> signalAbortTransaction;
fastsignals::signal<void (const App::Document&)> signalAbortTransaction;
//@}
/** @name Signals of property changes
@@ -308,13 +311,13 @@ public:
*/
//@{
/// signal on adding a dynamic property
boost::signals2::signal<void (const App::Property&)> signalAppendDynamicProperty;
fastsignals::signal<void (const App::Property&)> signalAppendDynamicProperty;
/// signal on renaming a dynamic property
boost::signals2::signal<void (const App::Property&, const char*)> signalRenameDynamicProperty;
fastsignals::signal<void (const App::Property&, const char*)> signalRenameDynamicProperty;
/// signal on about removing a dynamic property
boost::signals2::signal<void (const App::Property&)> signalRemoveDynamicProperty;
fastsignals::signal<void (const App::Property&)> signalRemoveDynamicProperty;
/// signal on about changing the editor mode of a property
boost::signals2::signal<void (const App::Document&, const App::Property&)> signalChangePropertyEditor;
fastsignals::signal<void (const App::Document&, const App::Property&)> signalChangePropertyEditor;
//@}
/** @name Signals of extension changes
@@ -324,9 +327,9 @@ public:
*/
//@{
/// signal before adding the extension
boost::signals2::signal<void (const App::ExtensionContainer&, std::string extension)> signalBeforeAddingDynamicExtension;
fastsignals::signal<void (const App::ExtensionContainer&, std::string extension)> signalBeforeAddingDynamicExtension;
/// signal after the extension was added
boost::signals2::signal<void (const App::ExtensionContainer&, std::string extension)> signalAddedDynamicExtension;
fastsignals::signal<void (const App::ExtensionContainer&, std::string extension)> signalAddedDynamicExtension;
//@}
// clang-format off
// NOLINTEND
+4
View File
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/***************************************************************************************************
* *
* Copyright (c) 2002 Jürgen Riegel <juergen.riegel@web.de> *
@@ -630,6 +631,9 @@ fs::path ApplicationDirectories::findHomePath(const char* sCall)
#include <cstdio>
#include <cstdlib>
#include <sys/param.h>
#if defined(__FreeBSD__)
#include <sys/sysctl.h>
#endif
fs::path ApplicationDirectories::findHomePath(const char* sCall)
{
+1
View File
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/***************************************************************************************************
* *
* Copyright (c) 2002 Jürgen Riegel <juergen.riegel@web.de> *
+56 -37
View File
@@ -1,38 +1,34 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
from __future__ import annotations
from Base.PyObjectBase import PyObjectBase
from typing import List
class ApplicationDirectories(PyObjectBase):
"""
App.ApplicationDirectories class.
Provides access to the directory versioning methods of its C++ counterpart.
For the time being this class only provides access to the directory versioning methods of its
C++ counterpart. These are all static methods, so no instance is needed. The main methods of
These are all static methods, so no instance is needed. The main methods of
this class are migrateAllPaths(), usingCurrentVersionConfig(), and versionStringForPath().
Author: Chris Hennes (chennes@pioneerlibrarysystem.org)
Licence: LGPL-2.1-or-later
DeveloperDocu: ApplicationDirectories
"""
@staticmethod
def usingCurrentVersionConfig(path:str) -> bool:
def usingCurrentVersionConfig(path: str, /) -> bool:
"""
usingCurrentVersionConfig(path)
Determine if a given config path is for the current version of the program.
Determine if a given config path is for the current version of the program
path : the path to check
Args:
path: The path to check.
"""
...
@staticmethod
def migrateAllPaths(paths: List[str]) -> None:
def migrateAllPaths(paths: list[str], /) -> None:
"""
migrateAllPaths(paths)
Migrate a set of versionable configuration directories from the given paths to a new version.
Migrate a set of versionable configuration directories from the given paths to a new
version. The new version's directories cannot exist yet, and the old ones *must* exist.
The new version's directories cannot exist yet, and the old ones *must* exist.
If the old paths are themselves versioned, then the new paths will be placed at the same
level in the directory structure (e.g., they will be siblings of each entry in paths).
If paths are NOT versioned, the new (versioned) copies will be placed *inside* the
@@ -41,6 +37,9 @@ class ApplicationDirectories(PyObjectBase):
If the list contains the same path multiple times, the duplicates are ignored, so it is safe
to pass the same path multiple times.
Args:
paths: List of paths to migrate from.
Examples:
Running FreeCAD 1.1, /usr/share/FreeCAD/Config/ -> /usr/share/FreeCAD/Config/v1-1/
Running FreeCAD 1.1, /usr/share/FreeCAD/Config/v1-1 -> raises exception, path exists
@@ -49,60 +48,80 @@ class ApplicationDirectories(PyObjectBase):
...
@staticmethod
def versionStringForPath(major:int, minor:int) -> str:
def versionStringForPath(major: int, minor: int, /) -> str:
"""
versionStringForPath(major, minor) -> str
Given a major and minor version number, return the name for a versioned subdirectory.
Given a major and minor version number, return a string that can be used as the name for a
versioned subdirectory. Only returns the version string, not the full path.
Args:
major: Major version number.
minor: Minor version number.
Returns:
A string that can be used as the name for a versioned subdirectory.
Only returns the version string, not the full path.
"""
...
@staticmethod
def isVersionedPath(startingPath:str) -> bool:
def isVersionedPath(startingPath: str, /) -> bool:
"""
isVersionedPath(startingPath) -> bool
Determine if a given path is versioned.
Determine if a given path is versioned (that is, if its last component contains
something that this class would have created as a versioned subdirectory). Returns true
for any path that the *current* version of FreeCAD would recognized as versioned, and false
for either something that is not versioned, or something that is versioned but for a later
version of FreeCAD.
That is, if its last component contains something that this class would have
created as a versioned subdirectory).
Args:
startingPath: The path to check.
Returns:
True for any path that the *current* version of FreeCAD would recognize as versioned,
and False for either something that is not versioned, or something that is versioned
but for a later version of FreeCAD.
"""
...
@staticmethod
def mostRecentAvailableConfigVersion(startingPath:str) -> str:
def mostRecentAvailableConfigVersion(startingPath: str, /) -> str:
"""
mostRecentAvailableConfigVersion(startingPath) -> str
Given a base path that is expected to contain versioned subdirectories, locate the
directory name (*not* the path, only the final component, the version string itself)
corresponding to the most recent version of the software, up to and including the current
running version, but NOT exceeding it -- any *later* version whose directories exist
in the path is ignored. See also mostRecentConfigFromBase().
Args:
startingPath: The path to check.
Returns:
Most recent available dir name (not path).
"""
...
@staticmethod
def mostRecentConfigFromBase(startingPath: str) -> str:
def mostRecentConfigFromBase(startingPath: str, /) -> str:
"""
mostRecentConfigFromBase(startingPath) -> str
Given a base path that is expected to contained versioned subdirectories, locate the
directory corresponding to the most recent version of the software, up to and including
the current version, but NOT exceeding it. Returns the complete path, not just the final
component. See also mostRecentAvailableConfigVersion().
Args:
startingPath: The base path to check.
Returns:
Most recent available full path (not just dir name).
"""
...
@staticmethod
def migrateConfig(oldPath: str, newPath: str) -> None:
def migrateConfig(oldPath: str, newPath: str, /) -> None:
"""
migrateConfig(oldPath, newPath) -> None
A utility method to copy all files and directories from oldPath to newPath, handling the
case where newPath might itself be a subdirectory of oldPath (and *not* attempting that
otherwise-recursive copy).
Args:
oldPath: Path from.
newPath: Path to.
"""
...
+1
View File
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/***************************************************************************************************
* *
* Copyright (c) 2025 The FreeCAD project association AISBL *
+2
View File
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/***************************************************************************
* Copyright (c) 2002 Jürgen Riegel <juergen.riegel@web.de> *
* *
+2
View File
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/****************************************************************************
* Copyright (c) 2019 Zheng Lei (realthunder) <realthunder.dev@gmail.com> *
* *
+2
View File
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/****************************************************************************
* Copyright (c) 2019 Zheng Lei (realthunder) <realthunder.dev@gmail.com> *
* *
+2
View File
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/***************************************************************************
* Copyright (c) 2015 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
+2
View File
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/***************************************************************************
* Copyright (c) 2015 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
+2
View File
@@ -1,3 +1,5 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
add_library(FreeCADApp SHARED)
if(WIN32)
+2
View File
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/***************************************************************************
* Copyright (c) 2005 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
+2
View File
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/***************************************************************************
* Copyright (c) 2005 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
+3 -2
View File
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/****************************************************************************
* *
* Copyright (c) 2002 Jürgen Riegel <juergen.riegel@web.de> *
@@ -199,12 +200,12 @@ const std::string& ComplexGeoData::elementMapPrefix()
std::string ComplexGeoData::getElementMapVersion() const
{
return "4";
return "5";
}
bool ComplexGeoData::checkElementMapVersion(const char* ver) const
{
return !boost::equals(ver, "3") && !boost::equals(ver, "4") && !boost::starts_with(ver, "3.");
return !boost::ends_with(ver, "5");
}
size_t ComplexGeoData::getElementMapSize(bool flush) const
+2 -1
View File
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/****************************************************************************
* *
* Copyright (c) 2002 Jürgen Riegel <juergen.riegel@web.de> *
@@ -279,7 +280,7 @@ public:
return _elementMap->setElementName(element, name, masterTag, sid, overwrite);
}
bool hasElementMap()
bool hasElementMap() const
{
return _elementMap != nullptr;
}
+47 -38
View File
@@ -1,12 +1,16 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
from __future__ import annotations
from Base.Metadata import export, constmethod
from Base.Persistence import Persistence
from Base.BoundBox import BoundBox as BoundBoxPy
from Base.BoundBox import BoundBox
from Base.Vector import Vector
from Base.Placement import Placement as PlacementPy
from Base.Placement import Placement
from Base.Rotation import Rotation
from Base.Matrix import Matrix
from StringHasher import StringHasher
from typing import Any, Final, List, Dict
from typing import Any, Final
@export(
@@ -15,89 +19,94 @@ from typing import Any, Final, List, Dict
)
class ComplexGeoData(Persistence):
"""
Data.ComplexGeoData class.
Author: Juergen Riegel (Juergen.Riegel@web.de)
Licence: LGPL
UserDocu: Father of all complex geometric data types
Father of all complex geometric data types.
"""
@constmethod
def getElementTypes(self) -> List[str]:
def getElementTypes(self) -> list[str]:
"""
Return a list of element types present in the complex geometric data
Return a list of element types present in the complex geometric data.
"""
...
@constmethod
def countSubElements(self) -> int:
"""
Return the number of elements of a type
Return the number of elements of a type.
"""
...
@constmethod
def getFacesFromSubElement(self) -> Any:
def getFacesFromSubElement(self, ) -> tuple[list[Vector], list[tuple[int, int, int]]]:
"""
Return vertexes and faces from a sub-element
Return vertexes and faces from a sub-element.
"""
...
@constmethod
def getLinesFromSubElement(self) -> Any:
def getLinesFromSubElement(self, ) -> tuple[list[Vector], list[tuple[int, int]]]:
"""
Return vertexes and lines from a sub-element
Return vertexes and lines from a sub-element.
"""
...
@constmethod
def getPoints(self) -> Any:
def getPoints(self) -> tuple[list[Vector], list[Vector]]:
"""
Return a tuple of points and normals with a given accuracy
"""
...
@constmethod
def getLines(self) -> Any:
def getLines(self) -> tuple[list[Vector], list[tuple[int, int]]]:
"""
Return a tuple of points and lines with a given accuracy
"""
...
@constmethod
def getFaces(self) -> Any:
def getFaces(self) -> tuple[list[Vector], list[tuple[int, int, int]]]:
"""
Return a tuple of points and triangles with a given accuracy
"""
...
def applyTranslation(self, translation: Vector) -> None:
def applyTranslation(self, translation: Vector, /) -> None:
"""
Apply an additional translation to the placement
"""
...
def applyRotation(self, rotation: Rotation) -> None:
def applyRotation(self, rotation: Rotation, /) -> None:
"""
Apply an additional rotation to the placement
"""
...
def transformGeometry(self, transformation: Matrix) -> None:
def transformGeometry(self, transformation: Matrix, /) -> None:
"""
Apply a transformation to the underlying geometry
"""
...
def setElementName(self, *, element: str, name: str = None, postfix: str = None, overwrite: bool = False, sid: Any = None) -> None:
def setElementName(
self,
*,
element: str,
name: str = None,
postfix: str = None,
overwrite: bool = False,
sid: Any = None,
) -> None:
"""
setElementName(element,name=None,postfix=None,overwrite=False,sid=None), Set an element name
Set an element name.
element : the original element name, e.g. Edge1, Vertex2
name : the new name for the element, None to remove the mapping
postfix : postfix of the name that will not be hashed
overwrite: if true, it will overwrite exiting name
sid : to hash the name any way you want, provide your own string id(s) in this parameter
Args:
element : the original element name, e.g. Edge1, Vertex2
name : the new name for the element, None to remove the mapping
postfix : postfix of the name that will not be hashed
overwrite: if true, it will overwrite exiting name
sid : to hash the name any way you want, provide your own string id(s) in this parameter
An element can have multiple mapped names. However, a name can only be mapped
to one element
@@ -105,33 +114,33 @@ class ComplexGeoData(Persistence):
...
@constmethod
def getElementName(self, name: str, direction: int = 0) -> Any:
def getElementName(self, name: str, direction: int = 0, /) -> str:
"""
getElementName(name,direction=0) - Return a mapped element name or reverse
Return a mapped element name or reverse.
"""
...
@constmethod
def getElementIndexedName(self, name: str) -> Any:
def getElementIndexedName(self, name: str, /) -> str | tuple[str, list[int]]:
"""
getElementIndexedName(name) - Return the indexed element name
Return the indexed element name.
"""
...
@constmethod
def getElementMappedName(self, name: str) -> Any:
def getElementMappedName(self, name: str, /) -> str | tuple[str, list[int]]:
"""
getElementMappedName(name) - Return the mapped element name
Return the mapped element name
"""
...
BoundBox: Final[BoundBoxPy] = ...
BoundBox: Final[BoundBox] = ...
"""Get the bounding box (BoundBox) of the complex geometric data."""
CenterOfGravity: Final[Vector] = ...
"""Get the center of gravity"""
Placement: PlacementPy = ...
Placement: Placement = ...
"""Get the current transformation of the object as placement"""
Tag: int = 0
@@ -143,10 +152,10 @@ class ComplexGeoData(Persistence):
ElementMapSize: Final[int] = 0
"""Get the current element map size"""
ElementMap: Dict[Any, Any] = {}
ElementMap: dict[str, str] = {}
"""Get/Set a dict of element mapping"""
ElementReverseMap: Final[Dict[Any, Any]] = {}
ElementReverseMap: Final[dict[str, str | list[str]]] = {}
"""Get a dict of element reverse mapping"""
ElementMapVersion: Final[str] = ""
+2
View File
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/***************************************************************************
* Copyright (c) 2007 Jürgen Riegel <juergen.riegel@web.de> *
* *
+11 -4
View File
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/***************************************************************************
* Copyright (c) 2015 Stefan Tröger <stefantroeger@gmx.net> *
* Copyright (c) 2015 Alexander Golubev (Fat-Zer) <fatzer2@gmail.com> *
@@ -179,10 +181,15 @@ App::DatumElement* LocalCoordinateSystem::getDatumElement(const char* role) cons
if (featIt != features.end()) {
return static_cast<App::DatumElement*>(*featIt);
}
std::stringstream err;
err << "LocalCoordinateSystem \"" << getFullName() << "\" doesn't contain feature with role \""
<< role << '"';
throw Base::RuntimeError(err.str().c_str());
// During restore, if role lookup fails (e.g. timing issues or fallback to internal name),
// we suppress the error. The default getSubObject will try to resolve it by Internal Name next.
if (!getDocument()->testStatus(App::Document::Restoring)) {
std::stringstream err;
err << "LocalCoordinateSystem \"" << getFullName()
<< "\" doesn't contain feature with role \"" << role << '"';
throw Base::RuntimeError(err.str().c_str());
}
return nullptr;
}
App::Line* LocalCoordinateSystem::getAxis(const char* role) const
+2
View File
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/***************************************************************************
* Copyright (c) 2015 Stefan Tröger <stefantroeger@gmx.net> *
* Copyright (c) 2015 Alexander Golubev (Fat-Zer) <fatzer2@gmail.com> *
+2
View File
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/***************************************************************************
* Copyright (c) 2002 Jürgen Riegel <juergen.riegel@web.de> *
* *
+34 -32
View File
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/***************************************************************************
* Copyright (c) 2002 Jürgen Riegel <juergen.riegel@web.de> *
* *
@@ -163,61 +165,61 @@ public:
//@{
// clang-format off
/// signal before changing an doc property
boost::signals2::signal<void(const Document&, const Property&)> signalBeforeChange;
fastsignals::signal<void(const Document&, const Property&)> signalBeforeChange;
/// signal on changed doc property
boost::signals2::signal<void(const Document&, const Property&)> signalChanged;
fastsignals::signal<void(const Document&, const Property&)> signalChanged;
/// signal on new Object
boost::signals2::signal<void(const DocumentObject&)> signalNewObject;
fastsignals::signal<void(const DocumentObject&)> signalNewObject;
/// signal on deleted Object
boost::signals2::signal<void(const DocumentObject&)> signalDeletedObject;
fastsignals::signal<void(const DocumentObject&)> signalDeletedObject;
/// signal before changing an Object
boost::signals2::signal<void(const DocumentObject&, const Property&)> signalBeforeChangeObject;
fastsignals::signal<void(const DocumentObject&, const Property&)> signalBeforeChangeObject;
/// signal on changed Object
boost::signals2::signal<void(const DocumentObject&, const Property&)> signalChangedObject;
fastsignals::signal<void(const DocumentObject&, const Property&)> signalChangedObject;
/// signal on manually called DocumentObject::touch()
boost::signals2::signal<void(const DocumentObject&)> signalTouchedObject;
fastsignals::signal<void(const DocumentObject&)> signalTouchedObject;
/// signal on relabeled Object
boost::signals2::signal<void(const DocumentObject&)> signalRelabelObject;
fastsignals::signal<void(const DocumentObject&)> signalRelabelObject;
/// signal on activated Object
boost::signals2::signal<void(const DocumentObject&)> signalActivatedObject;
fastsignals::signal<void(const DocumentObject&)> signalActivatedObject;
/// signal on created object
boost::signals2::signal<void(const DocumentObject&, Transaction*)> signalTransactionAppend;
fastsignals::signal<void(const DocumentObject&, Transaction*)> signalTransactionAppend;
/// signal on removed object
boost::signals2::signal<void(const DocumentObject&, Transaction*)> signalTransactionRemove;
fastsignals::signal<void(const DocumentObject&, Transaction*)> signalTransactionRemove;
/// signal on undo
boost::signals2::signal<void(const Document&)> signalUndo;
fastsignals::signal<void(const Document&)> signalUndo;
/// signal on redo
boost::signals2::signal<void(const Document&)> signalRedo;
fastsignals::signal<void(const Document&)> signalRedo;
/** signal on load/save document
* this signal is given when the document gets streamed.
* you can use this hook to write additional information in
* the file (like the Gui::Document does).
*/
boost::signals2::signal<void(Base::Writer&)> signalSaveDocument;
boost::signals2::signal<void(Base::XMLReader&)> signalRestoreDocument;
boost::signals2::signal<void(const std::vector<DocumentObject*>&, Base::Writer&)> signalExportObjects;
boost::signals2::signal<void(const std::vector<DocumentObject*>&, Base::Writer&)> signalExportViewObjects;
boost::signals2::signal<void(const std::vector<DocumentObject*>&, Base::XMLReader&)> signalImportObjects;
boost::signals2::signal<void(const std::vector<DocumentObject*>&, Base::Reader&,
fastsignals::signal<void(Base::Writer&)> signalSaveDocument;
fastsignals::signal<void(Base::XMLReader&)> signalRestoreDocument;
fastsignals::signal<void(const std::vector<DocumentObject*>&, Base::Writer&)> signalExportObjects;
fastsignals::signal<void(const std::vector<DocumentObject*>&, Base::Writer&)> signalExportViewObjects;
fastsignals::signal<void(const std::vector<DocumentObject*>&, Base::XMLReader&)> signalImportObjects;
fastsignals::signal<void(const std::vector<DocumentObject*>&, Base::Reader&,
const std::map<std::string, std::string>&)> signalImportViewObjects;
boost::signals2::signal<void(const std::vector<DocumentObject*>&)> signalFinishImportObjects;
fastsignals::signal<void(const std::vector<DocumentObject*>&)> signalFinishImportObjects;
// signal starting a save action to a file
boost::signals2::signal<void(const Document&, const std::string&)> signalStartSave;
fastsignals::signal<void(const Document&, const std::string&)> signalStartSave;
// signal finishing a save action to a file
boost::signals2::signal<void(const Document&, const std::string&)> signalFinishSave;
boost::signals2::signal<void(const Document&)> signalBeforeRecompute;
boost::signals2::signal<void(const Document&, const std::vector<DocumentObject*>&)> signalRecomputed;
boost::signals2::signal<void(const DocumentObject&)> signalRecomputedObject;
fastsignals::signal<void(const Document&, const std::string&)> signalFinishSave;
fastsignals::signal<void(const Document&)> signalBeforeRecompute;
fastsignals::signal<void(const Document&, const std::vector<DocumentObject*>&)> signalRecomputed;
fastsignals::signal<void(const DocumentObject&)> signalRecomputedObject;
// signal a new opened transaction
boost::signals2::signal<void(const Document&, std::string)> signalOpenTransaction;
fastsignals::signal<void(const Document&, std::string)> signalOpenTransaction;
// signal a committed transaction
boost::signals2::signal<void(const Document&)> signalCommitTransaction;
fastsignals::signal<void(const Document&)> signalCommitTransaction;
// signal an aborted transaction
boost::signals2::signal<void(const Document&)> signalAbortTransaction;
boost::signals2::signal<void(const Document&, const std::vector<DocumentObject*>&)> signalSkipRecompute;
boost::signals2::signal<void(const DocumentObject&)> signalFinishRestoreObject;
boost::signals2::signal<void(const Document&, const Property&)> signalChangePropertyEditor;
boost::signals2::signal<void(std::string)> signalLinkXsetValue;
fastsignals::signal<void(const Document&)> signalAbortTransaction;
fastsignals::signal<void(const Document&, const std::vector<DocumentObject*>&)> signalSkipRecompute;
fastsignals::signal<void(const DocumentObject&)> signalFinishRestoreObject;
fastsignals::signal<void(const Document&, const Property&)> signalChangePropertyEditor;
fastsignals::signal<void(std::string)> signalLinkXsetValue;
// clang-format on
//@}
// NOLINTEND
+123 -82
View File
@@ -1,13 +1,15 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
from __future__ import annotations
from PropertyContainer import PropertyContainer
from DocumentObject import DocumentObject
from typing import Final, List, Tuple, Sequence
from typing import Final, Sequence
class Document(PropertyContainer):
"""
This is a Document class
Author: Juergen Riegel (FreeCAD@juergen-riegel.net)
Licence: LGPL
This is the Document class.
"""
DependencyGraph: Final[str] = ""
@@ -16,16 +18,16 @@ class Document(PropertyContainer):
ActiveObject: Final[DocumentObject] = None
"""The last created object in this document"""
Objects: Final[List[DocumentObject]] = []
Objects: Final[list[DocumentObject]] = []
"""The list of objects in this document"""
TopologicalSortedObjects: Final[List[DocumentObject]] = []
TopologicalSortedObjects: Final[list[DocumentObject]] = []
"""The list of objects in this document in topological sorted order"""
RootObjects: Final[List[DocumentObject]] = []
RootObjects: Final[list[DocumentObject]] = []
"""The list of root objects in this document"""
RootObjectsIgnoreLinks: Final[List[DocumentObject]] = []
RootObjectsIgnoreLinks: Final[list[DocumentObject]] = []
"""The list of root objects in this document ignoring references from links."""
UndoMode: int = 0
@@ -40,10 +42,10 @@ class Document(PropertyContainer):
RedoCount: Final[int] = 0
"""Number of possible Redos"""
UndoNames: Final[List[str]] = []
UndoNames: Final[list[str]] = []
"""A list of Undo names"""
RedoNames: Final[List[str]] = []
RedoNames: Final[list[str]] = []
"""A List of Redo names"""
Name: Final[str] = ""
@@ -55,10 +57,10 @@ class Document(PropertyContainer):
HasPendingTransaction: Final[bool] = False
"""Check if there is a pending transaction"""
InList: Final[List["Document"]] = []
InList: Final[list[Document]] = []
"""A list of all documents that link to this document."""
OutList: Final[List["Document"]] = []
OutList: Final[list[Document]] = []
"""A list of all documents that this document links to."""
Restoring: Final[bool] = False
@@ -84,25 +86,25 @@ class Document(PropertyContainer):
def save(self) -> None:
"""
Save the document to disk
Save the document to disk.
"""
...
def saveAs(self) -> None:
def saveAs(self, path: str, /) -> None:
"""
Save the document under a new name to disk
Save the document under a new name to disk.
"""
...
def saveCopy(self) -> None:
def saveCopy(self, path: str, /) -> None:
"""
Save a copy of the document under a new name to disk
Save a copy of the document under a new name to disk.
"""
...
def load(self) -> None:
def load(self, path: str, /) -> None:
"""
Load the document from the given path
Load the document from the given path.
"""
...
@@ -131,37 +133,40 @@ class Document(PropertyContainer):
"""
...
def getUniqueObjectName(self, objName: str) -> str:
def getUniqueObjectName(self, objName: str, /) -> str:
"""
getUniqueObjectName(objName) -> objName
Return the same name, or the name made unique, for Example Box -> Box002 if there are conflicting name
already in the document.
ObjName : str
Object name.
Args:
objName: Object name candidate.
Returns:
Unique object name based on objName.
"""
...
def mergeProject(self) -> None:
def mergeProject(self, path: str, /) -> None:
"""
Merges this document with another project file
Merges this document with another project file.
"""
...
def exportGraphviz(self) -> None:
def exportGraphviz(self, path: str = None, /) -> str | None:
"""
Export the dependencies of the objects as graph
Export the dependencies of the objects as graph.
If path is passed, graph is written to it. if not a string is returned.
"""
...
def openTransaction(self, name: str) -> None:
def openTransaction(self, name: str, /) -> None:
"""
openTransaction(name) - Open a new Undo/Redo transaction.
Open a new Undo/Redo transaction.
This function no long creates a new transaction, but calls
FreeCAD.setActiveTransaction(name) instead, which will auto creates a
transaction with the given name when any change happed in any opened document.
transaction with the given name when any change happened in any opened document.
If more than one document is changed, all newly created transactions will have
the same internal ID and will be undo/redo together.
"""
@@ -181,7 +186,6 @@ class Document(PropertyContainer):
def addObject(
self,
*,
type: str,
name: str = None,
objProxy: object = None,
@@ -190,24 +194,22 @@ class Document(PropertyContainer):
viewType: str = None,
) -> DocumentObject:
"""
addObject(type, name=None, objProxy=None, viewProxy=None, attach=False, viewType=None)
Add an object to document.
Add an object to document
type (String): the type of the document object to create.
name (String): the optional name of the new object.
objProxy (Object): the Python binding object to attach to the new document object.
viewProxy (Object): the Python binding object to attach the view provider of this object.
attach (Boolean): if True, then bind the document object first before adding to the document
to allow Python code to override view provider type. Once bound, and before adding to
the document, it will try to call Python binding object's attach(obj) method.
viewType (String): override the view provider type directly, only effective when attach is False.
Args:
type: the type of the document object to create.
name: the optional name of the new object.
objProxy: the Python binding object to attach to the new document object.
viewProxy: the Python binding object to attach the view provider of this object.
attach: if True, then bind the document object first before adding to the document
to allow Python code to override view provider type. Once bound, and before adding to
the document, it will try to call Python binding object's attach(obj) method.
viewType: override the view provider type directly, only effective when attach is False.
"""
...
def addProperty(
self,
*,
type: str,
name: str,
group: str = "",
@@ -216,22 +218,37 @@ class Document(PropertyContainer):
read_only: bool = False,
hidden: bool = False,
locked: bool = False,
) -> "Document":
enum_vals: list[str] | None = None,
) -> Document:
"""
addProperty(type: string, name: string, group="", doc="", attr=0, read_only=False, hidden=False, locked=False) -- Add a generic property.
Add a generic property.
Args:
type: The type of the property to add.
name: The name of the property.
group: The group to which the property belongs. Defaults to "".
doc: The documentation string for the property. Defaults to "".
attr: Attribute flags for the property. Defaults to 0.
read_only: Whether the property is read-only. Defaults to False.
hidden: Whether the property is hidden. Defaults to False.
locked: Whether the property is locked. Defaults to False.
Returns:
The document instance with the added property.
"""
...
def removeProperty(self, string: str) -> None:
def removeProperty(self, name: str, /) -> None:
"""
removeProperty(string) -- Remove a generic property.
Remove a generic property.
Note, you can only remove user-defined properties but not built-in ones.
"""
...
def removeObject(self) -> None:
def removeObject(self, name: str, /) -> None:
"""
Remove an object from the document
Remove an object from the document.
"""
...
@@ -241,34 +258,39 @@ class Document(PropertyContainer):
*,
recursive: bool = False,
return_all: bool = False,
) -> Tuple[DocumentObject, ...]:
) -> tuple[DocumentObject, ...]:
"""
copyObject(object, recursive=False, return_all=False)
Copy an object or objects from another document to this document.
object: can either be a single object or sequence of objects
recursive: if True, also recursively copies internal objects
return_all: if True, returns all copied objects, or else return only the copied
object corresponding to the input objects.
Args:
object: can either be a single object or sequence of objects
recursive: if True, also recursively copies internal objects
return_all: if True, returns all copied objects, or else return only the copied
object corresponding to the input objects.
"""
...
def moveObject(
self, object: DocumentObject, with_dependencies: bool = False
self,
object: DocumentObject,
with_dependencies: bool = False,
/,
) -> DocumentObject:
"""
moveObject(object, bool with_dependencies = False)
Transfers an object from another document to this document.
object: can either a single object or sequence of objects
with_dependencies: if True, all internal dependent objects are copied too.
Args:
object: can either a single object or sequence of objects
with_dependencies: if True, all internal dependent objects are copied too.
"""
...
def importLinks(self, object: DocumentObject = None) -> Tuple[DocumentObject, ...]:
def importLinks(
self,
object: DocumentObject = None,
/,
) -> tuple[DocumentObject, ...]:
"""
importLinks(object|[object...])
Import any externally linked object given a list of objects in
this document. Any link type properties of the input objects
will be automatically reassigned to the imported object
@@ -302,7 +324,7 @@ class Document(PropertyContainer):
"""
...
def setClosable(self, closable: bool) -> None:
def setClosable(self, closable: bool, /) -> None:
"""
Set a flag that allows or forbids to close a document
"""
@@ -314,7 +336,7 @@ class Document(PropertyContainer):
"""
...
def setAutoCreated(self, autoCreated: bool) -> None:
def setAutoCreated(self, autoCreated: bool, /) -> None:
"""
Set a flag that indicates if a document is autoCreated
"""
@@ -326,9 +348,15 @@ class Document(PropertyContainer):
"""
...
def recompute(self, objs: Sequence[DocumentObject] = None) -> int:
def recompute(
self,
objs: Sequence[DocumentObject] = None,
force: bool = False,
check_cycle: bool = False,
/,
) -> int:
"""
recompute(objs=None): Recompute the document and returns the amount of recomputed features
Recompute the document and returns the amount of recomputed features.
"""
...
@@ -350,41 +378,55 @@ class Document(PropertyContainer):
"""
...
def getObject(self, name: str) -> DocumentObject:
def getObject(self, name: str, /) -> DocumentObject:
"""
Return the object with the given name
"""
...
def getObjectsByLabel(self, label: str) -> List[DocumentObject]:
def getObjectsByLabel(self, label: str, /) -> list[DocumentObject]:
"""
Return the objects with the given label name.
NOTE: It's possible that several objects have the same label name.
"""
...
def findObjects(
self, *, Type: str = None, Name: str = None, Label: str = None
) -> List[DocumentObject]:
self,
Type: str = None,
Name: str = None,
Label: str = None,
) -> list[DocumentObject]:
"""
findObjects([Type=string], [Name=string], [Label=string]) -> list
Return a list of objects that match the specified type, name or label.
Name and label support regular expressions. All parameters are optional.
Args:
Type: Type of the feature.
Name: Name
Label: Label
"""
...
def getLinksTo(
self, obj: DocumentObject, options: int = 0, maxCount: int = 0
) -> Tuple[DocumentObject, ...]:
self,
obj: DocumentObject,
options: int = 0,
maxCount: int = 0,
/,
) -> tuple[DocumentObject, ...]:
"""
getLinksTo(obj, options=0, maxCount=0): return objects linked to 'obj'
Return objects linked to 'obj'
options: 1: recursive, 2: check link array. Options can combine.
maxCount: to limit the number of links returned
Args:
options: 1: recursive, 2: check link array. Options can combine.
maxCount: to limit the number of links returned.
"""
...
def supportedTypes(self) -> List[str]:
def supportedTypes(self) -> list[str]:
"""
A list of supported types of objects
"""
@@ -396,12 +438,11 @@ class Document(PropertyContainer):
"""
...
def getDependentDocuments(self, sort: bool = True) -> List[DocumentObject]:
def getDependentDocuments(self, sort: bool = True, /) -> list[DocumentObject]:
"""
getDependentDocuments(sort=True)
Returns a list of documents that this document directly or indirectly links to including itself.
sort: whether to topologically sort the return list
Args:
sort: whether to topologically sort the return list
"""
...
+54
View File
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/***************************************************************************
* Copyright (c) 2011 Jürgen Riegel <juergen.riegel@web.de> *
* Copyright (c) 2011 Werner Mayer <wmayer[at]users.sourceforge.net> *
@@ -30,6 +32,7 @@
#include <Base/Console.h>
#include <Base/Matrix.h>
#include <Base/Placement.h>
#include <Base/Tools.h>
#include <Base/Writer.h>
@@ -1615,3 +1618,54 @@ void DocumentObject::onPropertyStatusChanged(const Property& prop, unsigned long
getDocument()->signalChangePropertyEditor(*getDocument(), prop);
}
}
Base::Placement DocumentObject::getPlacementOf(const std::string& sub, DocumentObject* targetObj)
{
Base::Placement plc;
auto* propPlacement = freecad_cast<App::PropertyPlacement*>(getPropertyByName("Placement"));
if (propPlacement) {
// If the object has no placement (like a Group), plc stays identity so we can proceed.
plc = propPlacement->getValue();
}
std::vector<std::string> names = Base::Tools::splitSubName(sub);
if (names.empty() || this == targetObj) {
return plc;
}
DocumentObject* subObj = getDocument()->getObject(names.front().c_str());
if (!subObj) {
return plc;
}
std::vector<std::string> newNames(names.begin() + 1, names.end());
std::string newSub = Base::Tools::joinList(newNames, ".");
return plc * subObj->getPlacementOf(newSub, targetObj);
}
Base::Placement DocumentObject::getPlacement() const
{
Base::Placement plc;
if (auto* prop = getPlacementProperty()) {
plc = prop->getValue();
}
return plc;
}
App::PropertyPlacement* DocumentObject::getPlacementProperty() const
{
if (auto linkExtension = getExtensionByType<App::LinkBaseExtension>(true)) {
if (auto linkPlacementProp = linkExtension->getLinkPlacementProperty()) {
return linkPlacementProp;
}
return linkExtension->getPlacementProperty();
}
return getPropertyByName<App::PropertyPlacement>("Placement");
}

Some files were not shown because too many files have changed in this diff Show More