Before 0aed23c (PR #19582), external geometry projection used a different algorithm and produced slightly different geometry for some kinds of projections (B-splines in particular). This adds a backwards-compatibility path that allows old files to continue to use the old algorithm, while using the new and improved algorithm with new files.
Commit a346c266 (PR #21794) was a major refactoring of the extrusion code, and one consequence of it was that the 'TwoLengths' extrusion was deprecated and replaced. The code that replaced it generated the same final geometry, but in the opposite direction, changing the face order and breaking the element names. This commit adds a backwards-compatibility branch to the file loading code that flips the direction of the inputs, so the final output matches the original.
* PD: Hole Thread texture
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* refactor: vp-texture remove logging
* refactor: vp-hole cleanup unused declaration
* refactor: vp-hole remove logging
* refactor: vp-hole use convertTo
* refactor: vp-hole use freecad_cast
* refactor: make unwrapsurface private
* fix: logic error with model-thread handling
* fix: modelthreadchanged issues
threaddepth doesnt depend on modeled or not so remove it
* fix: model thread getting disabled when it shouldnt
* revert: use base-0 poly triangulation
previously had issues, but all is good now
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Gui: fix quantity spinbox size not adapting to number of decimals
* Gui: fix quantity spinbox units getting cut (force max chars)
* Gui: editableDatumLabel remove hardcoded values
* fixes
* Gui: sketcher ovp auto adjust size
* Gui: ovp fix cursor jumping behind the unit
* Gui: Refactor changes to QuantitySpinBox
The QuantitySpinBox uses d-pointer (pimpl) to store its private data -
this commit ensures that all state is stored here and exposed via
getters and setters + qproperties.
* Gui: sketcher ovp fix cursor jumping after the unit
* Gui: allow quantitySpinBox to set max digits allowed
Useful for adjustable width in the Sketcher OVP
---------
Co-authored-by: Kacper Donat <kadet1090@gmail.com>
* Sketcher: Fix: Arc of Hyperbola
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Added minor grater than major radius support
* Fixed merge errors
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Improved comments and added a confused points check for S1 and S2 distance.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Added compile check for occ version and check before getting minor radius.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Apply suggestions from code review
OCC version check
Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>
When Part2DObject (e.g., Sketch) is created, it calls setAttacher() to
set up AttachEnginePlane. This updated the internal AttacherType property
but left the user-visible AttacherEngine enum at its default "Engine 3D".
Now setAttacher() also updates AttacherEngine for non-base attachers,
keeping the visible property in sync with the actual engine type.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Core: Fix freecad when Windows username has non ASCII characters
* Update ApplicationDirectories.cpp
* Tests: Add tests of pathToString/stringToPath
Validates the fix for non-ASCII characters in filesystem paths (e.g.
Windows usernames with umlauts). Includes Windows-specific tests that
verify pathToString produces UTF-8 from wide-string paths and that
the naive fs::path::string() does not. On Linux these functions are
effectively a no-op, so the tests themselves are only really useful
on Windows.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Python interface to the setCamera() is using 's' format string, which
converts Unicode object to C string using 'utf-8' encoding. Reflect
that for QString conversion as well.
CAM: CircularHoleBase - Fix onDocumentRestored
Removed the expermental "Automatic TSP" sorting mode and ensured legacy
files are migrated to "Automatic". Start using C++ TSP sorting for
"Automatic" mode for better performance. Refactored natural sorting for
table columns, relocating the utility class for reuse and using a robust
sort key.
src/Mod/CAM/Path/Op/CircularHoleBase.py:
- Removed "Automatic TSP" from SortingMode options and logic
- Added migration logic for legacy "Automatic TSP" values
- Cleaned up redundant assignments
src/Mod/CAM/Path/Op/Gui/CircularHoleBase.py:
- Updated to use relocated NaturalSortTableWidgetItem for feature and
diameter columns
- Improved sorting behavior for mixed text/number columns
src/Mod/CAM/Path/Base/Gui/Util.py:
- Added NaturalSortTableWidgetItem using the existing natural_sort_key
for robust sorting
This update enhances the GUI with new sorting modes and manual reordering, and
adds migration logic to ensure robust property
src/Mod/CAM/Gui/Resources/panels/PageBaseHoleGeometryEdit.ui:
- Add Sorting mode combo box with "Automatic", "Automatic TSP", and "Manual" options
- Add UI improvements for hole sorting, selection, and filtering
src/Mod/CAM/Path/Op/CircularHoleBase.py:
- Add migration logic to ensure SortingMode property exists and is up to date
- Use sort_locations_tsp when SortingMode is "Automatic TSP"
src/Mod/CAM/Path/Op/Gui/CircularHoleBase.py:
- Add RowMoveTableWidget for manual row reordering in the GUI
- Update TaskPanelHoleGeometryPage to support new sorting modes and improved UI behavior
CAM: Add template dropdown below machine name in editor
Adds a template selection dropdown to the Machine Editor dialog,
positioned below the machine name field. Dropdown lists user and
built-in templates for new machines only. Adds MachineFactory
template discovery and ensures templates are copied to build directory.
src/Mod/CAM/CMakeLists.txt:
- Copy machine templates to build directory for runtime access
src/Mod/CAM/Machine/models/machine.py:
- Add MachineFactory.list_builtin_templates() for template discovery
- Use FreeCAD install path for built-in templates
src/Mod/CAM/Machine/ui/editor/machine_editor.py:
- Add template dropdown below name field for new machines
- Populate dropdown with user and built-in templates
- Update UI fields when template is selected
Major improvements to the GenericPlasma postprocessor with new dialog-based
mode selection and robust plasma cutting features.
New Features:
- Add pre_processing_dialog() for interactive mode selection
- Replace persistent mark_entry_only property with runtime dialog
- User-friendly choice between Normal Cutting and Mark Entry Points Only
- Enhanced torch control with pierce height movement
- Complete mark_entry_only implementation with proper marking sequence
- Improved error handling and state management
Technical Improvements:
- Add _reset_plasma_state() for clean per-operation tracking
- Fix Z direction detection with proper null checking
- Enhanced height extraction from StartDepth/FinalDepth/ClearanceHeight
- Better error handling with debug logging
- Graceful fallback when GUI not available
Bug Fixes:
- Fix torch control to move to pierce height before ignition
- Fix force_rapid_feeds to remove F parameters (revert from override)
- Fix state tracking initialization and null value handling
- Add proper state reset for each operationUses a dialog to set mark_only.
Co-authored-by: tarman3 <joice501790018@tutamail.com>
Clicking the eye icon on the constraints panel hides all constraints. This calls SketchObject::setVirtualSpace where the existing Constraint
objects will be replaced. However, the Constraint objects are also stored inside the member 'solvedSketch' but won't be replaced so that the
pointers there will become dangling.
If the user starts to drag the sketch the pointers are still dangling and cause a crash when calling 'solvedSketch.moveGeometries'.
The crash can be reproduced with:
1. Create a sketch
2. Add a single line
3. Set a length constraint
4. Make it a non-driving constraint
5. Hide it with the eye icon or by unticking the check box
6. Move the line
The same crash also occurs when calling the methods setLabelDistance() or setLabelPosition() from Python and then trying to move the sketch.
Solution:
To fix the problem add the lightweight method 'Sketch::updateConstraints' and call it inside SketchObject::setVirtualSpace to quickly update
the pointers after invalidating them.
This fixes issue 19566
Related to #25004
Updated the tooltips to point to correct pref pages.
Additionally:
* Minor text tweaks.
* Replaced "Gui::PrefColorButton" with "Gui::ColorButton".
* BIM: fix BuildingPart color issues including v1.0 regressions
Fixes#27136.
* [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>
Corrects logic so that the _shape_type is saved properly and not always
defaulted to the primary toolbit type. Ensures subclass/alias
information is preserved when saving toolbits.
src/Mod/CAM/Path/Tool/toolbit/models/base.py:
- Fix fallback logic for _shape_type to correctly save subclass/alias
when present
- Only default to primary type if _shape_type is missing or matches the
main class
src/Mod/CAM/Path/Tool/docobject/ui/docobject.py:
- Improve label formatting by handling underscores, hyphens, and extra
spaces
src/Mod/CAM/Path/Tool/toolbit/ui/typefilter.py:
- Simplify type filter mapping and display logic for toolbit subtypes
* [TD]fix 3d point object reference in dimension
* [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>
Add missing break after hiding rectangle points for a void bounding box,
preventing fall-through to CornerMin()/CornerMax() which would produce
undefined values.
Remove the openCommand() call in editDoubleClicked() since
EditTextDialog already manages its own command lifecycle. The redundant
outer command was never closed when the user cancelled the dialog.
Escape user-provided text and font path strings before inserting them
into the Python command string, preventing breakage or injection from
strings containing quotes or backslashes.
Replace the character-by-character positioning loop with HarfBuzz
text shaping. The old code used FT_Get_Kerning which only reads
legacy kern tables. HarfBuzz handles both GPOS kerning and legacy
kern tables, as well as ligatures and complex script shaping.
* Add status bar hints for modifier keys in Std_Measure
* Align status bar hints according to design guide
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update src/Mod/Measure/Gui/TaskMeasure.cpp
Co-authored-by: Max Wilfinger <6246609+maxwxyz@users.noreply.github.com>
* Update src/Mod/Measure/Gui/TaskMeasure.cpp
Co-authored-by: Max Wilfinger <6246609+maxwxyz@users.noreply.github.com>
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Replace 'invert' with 'toggle' to improve readability
* Added missing namespace qualifier
* Fix MSVC list assignment errors with explicit std::list<InputHint>
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* fix InputHint': undeclared identifier
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Max Wilfinger <6246609+maxwxyz@users.noreply.github.com>
* Assembly: add support for draft links
* Update AssemblyObject.cpp
* Update ViewProviderAssembly.cpp
* Update GeoFeature.cpp
* Update JointObject.py
* [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
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
During conversion of some materials from the originals, in some cases authorship
was lost, or licensing mistaken. In addition, during their creation some files
had incorrect licenses applied. Files previously licensed LGPL-2.1.-or-later had
that license restored. Other files were re-licensed by agreement of their
author.
Co-Authored-By: David Carter <dcarter@davidcarter.ca>
Fixes#17661.
Fixes#27396.
In ArchSectionPlane.py the shape of BuildingParts was also processed. This resulted in duplicate geometry as BuildingParts inherit their shape from their (also processed) content.
This PR requires some testing, it should not be backported to v1.1.
* Fix Collada exporter skipping App::Link geometry
Resolve App::Link objects recursively during export so referenced
geometry is included in the .dae output while preserving link placement.
* Arch: Fix Collada export for App::Link objects
The Collada exporter skipped geometry for App::Link instances because
it only handled objects directly present in the document.
This change resolves Link objects using getLinkedObject() and exports
their referenced geometry while applying the placement of the exporting
instance.
The original App::Part expansion behavior is preserved.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Arch: fix placement handling for App::Link and primitives in Collada export
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* final change
* [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>
* Fix Linux SpaceMouse jerkiness: coalesce spnav events and batch camera updates
On Linux, pollSpacenav() posts every spnav motion event individually
(125-250Hz from spacenavd), each triggering a full scene redraw. Combined
with camera->orientation and camera->position each triggering separate
Coin3D notifications, this results in up to 500 redraws/sec.
Fix 1 - Event coalescing (GuiNativeEventLinux.cpp):
The drain loop now keeps only the latest motion state and posts once after
all pending events are consumed. SpaceMouse events are absolute deflection
(current puck position), not deltas, so the latest event always contains
the complete state.
Fix 2 - Batched camera updates (NavigationStyle.cpp):
Wrap camera property changes in enableNotify(false/true) + touch() so
Coin3D fires a single redraw instead of two per event.
Together this reduces redraws from ~500/sec to ~60/sec (display refresh),
eliminating the jerky navigation that Linux users experience with complex
models.
Fixes#25926
* Add per-axis deadzone filtering for Linux SpaceMouse
Each SpaceMouse axis has different sensitivity and noise characteristics.
A single global deadzone is too coarse — rotation axes may need different
thresholds than translation axes.
Read per-axis deadzone values from user.cfg (BaseApp/Spaceball/Motion)
using keys PanLRDeadzone, PanUDDeadzone, ZoomDeadzone, TiltDeadzone,
RollDeadzone, SpinDeadzone. Values default to 0 (no filtering).
Axis values below their individual threshold are zeroed before posting
the motion event, preventing unintended drift from sensor noise while
preserving intentional small movements.
This is the Linux equivalent of deadzone handling that NavLib provides
on Windows/macOS.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Use std::array for axisDeadzoneKeys to avoid magic number
Replace C-style array with std::array and use .size() instead of
hardcoded loop bound, as suggested in code review.
* Cache deadzone values with ParameterGrp Observer instead of polling
Replace per-event GetParameterGroupByPath + GetInt calls with a static
DeadzoneCache that loads values once and updates them via
ParameterGrp::ObserverType when user.cfg changes. Also use
static constexpr for the keys array and std::abs for readability.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Move DeadzoneCache from static local to member variable
Replace the static local DeadzoneCache in pollSpacenav() with a
std::unique_ptr<DeadzoneCache> member of GuiNativeEvent, initialized
in initSpaceball() after the spnav connection is established.
Forward-declare in the header to keep includes minimal.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: Maik-0000FF <Maik-0000FF@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Base: Added Quantities for Optic/Chemical mechanics
* [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>
Remove the TestSketcherGui file entirely, it contained only commented
lines. Delete commented out debugging output. Remove other commented-out
code that didn't have any explanation or justification for leaving it
in.
This method aims to solve the problem of untranslatable description
strings on file types. Some, but not all, file format description
strings contain translatable elements. For example, some languages
may translate "FEM mesh formats". Many format descriptions include
the words "file," "format," or "mesh" -- these could potentially be
replaced with localized versions.
This commit prevents unhandled exceptions to be thrown in the Add
Property dialog. When the user provides a valid name, for example 'Abc'
and then an invalid name, for example 'Abc^', an exception is thrown
that is caught by Qt's notify which may lead to a crash. This is caused
by the fact that the editor is still bound to the old property that has
been removed. The main idea was to preserve values that were provided
by the user as long as possible, also when a property name changes.
This design goal tried to preserve the user provided value even if the
property name is not valid. Although the underlying property item is
explicitly unbound in that situation, the editor is not.
The solution is to also explicitly unbind the editor if there is an
editor that can have bindings. Unbinding an editor does not
automatically hide the f(x) symbol in the editor (leading to errors on
unbound editors), so this commit also adds a bit of logic to hide
the f(x) symbol when an editor is unbound.
The memory is allocated using new() with alignment requirements, and
should be deleted using the same alignment requirement. See
issue #27781 for the valgrind error.
* Sketcher: Fix crash on external deletion
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update SketchObject.pyi
* Update SketchObjectPyImp.cpp
* Update ViewProviderSketch.cpp
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update SketchObjectPyImp.cpp
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Sketcher: Fix last external not being removed from ref 27719
* Update SketchObject.cpp
* Update SketchObject.cpp
* Update SketchObject.h
* [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
* rename fixMissingAxisInExternalGeo
* Update SketchObject.cpp
* Update SketchObjectPyImp.cpp
* [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>
* App: add PropertyListsT::removeIf()
For convenient list value filtering.
Co-authored-by: Zheng Lei <realthunder.dev@gmail.com>
* Update Property.h
* Update Property.h
* Assembly: Fix JCS position if assembly is transformed
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* redrawJointPlacement & showPreviewJCS Refactor to avoid duplicate code
* Assembly: JointObject: Simplify setJCSPosition
Co-authored-by: Benjamin Nauck <benjamin@nauck.se>
* Update JointObject.py
* Update src/Mod/Assembly/JointObject.py
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Benjamin Nauck <benjamin@nauck.se>
Adjusted G code output to include FreeCAD body and job information.
The first comment in the G code is shown on the machine controller,
and should contain useful information for operators to to identify
jobs. Fetch the body and job label using findParentJob and insert it
into the G code. For some reason the body and job information is not
available when called from TestFanucPost.py, so handle case where it
is undefined as earlier. This new use of findParentJob exposes error
in mock code used in code tests. This is fixed in a different pull
request to make this patch easily backportable to the 1.1 branch.
Fixed issues with Fanuc post processor discovered by lint. Made sure
global variables used are declared. This fixes issue updating the
postamble and preamble introduced in
ef794c31bd
Added docstrings, adjusted import statements and wrapped long line to
keep linter happy.
Reformatted code with black for consistent formatting.
Also reverted obsolete setText() workaround from commit
9c78ced00c now
that https://github.com/FreeCAD/FreeCAD/pull/26008 is merged.
* [ArchWall] Multi-Material width return to Width Property
Fix#27804
- BIM: Wall with MultiMaterial assigned reports wrong Width
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* [ArchWall] Multi-Material width return to Width Property (rev.)
Fix#27804
- BIM: Wall with MultiMaterial assigned reports wrong Width
(rev.
Better algorithm - https://github.com/FreeCAD/FreeCAD/issues/27804#issuecomment-3986056788)
* [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>
* BIM: Fix placement jump when uncloning objects
The Unclone command incorrectly multiplied the parent's placement by the
clone's placement. Since Arch clones store absolute placement (not
relative to the parent), this resulted in a double transform.
This caused baseless walls to jump to a new position upon uncloning.
Standard base-backed walls often masked this bug because their local
placement is usually Identity (0,0,0), but they would also fail if moved
independently of their base.
This fix assigns the clone's current placement directly to the new
object, preserving its position.
Fixes https://github.com/FreeCAD/FreeCAD/issues/26929
* BIM: do placement assignment and recompute only once
Fixes#28013.
When creating a structure from a profile the code could ignore `self.bmode` (beam-mode) and create a beam even if the user selected the column option in the task panel.
Rounding errors due to the conversion of numerical values read from the input boxes triggered the bug (89mm -> 3.5" -> 88.89999999999999mm).
But beyond that, it is IMO not correct to disregard user input. If the column option is specified, a column should be created irrespective of the dimensions.
* added shortcut for save copy
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Ctrl+Alt+Shift+S to save a copy
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: Parag Debnath <paragforwork@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
The current post processor fail completely for any operation because the
ShapeName attribute no longer exist. Changed code to look for attributes
present in FreeCAD 1.1 and master branch. Rewrote thread tapping code
to work with new tapping support. Switched thread tapping to use feed in
distance per minute (G94) instead of earlier distance per revolution to
avoid switching between mm/min and mm/rev for different operations.
Fixes#27814
* Changed Insert Component parts list to be collapsed by default
* only collapse large assemblies and only expand first child.
---------
Co-authored-by: Adam Spontarelli <adam@vector-space.org>
If a datum line is used as base shape then it causes a segmentation
fault because the shape is infinite that the CAD kernel fails with.
Solution:
Explicitly check beforehand if the shape is infinite or null.
This fixes issue 21429
Change Command::_assureWorkbench to check if the passed workbench is
disabled or not. If yes then do nothing.
This fixes issue 21477.
Hint: The method Application::activateWorkbench() is still able to
activate a disabled workbench
When pressing the Apply button the fem mesh feature is computed but still
marked as touched. When pressing the OK button it will be recomputed even
if nothing has changed. To avoid the superfluous recompute purge the
touched flag when the Apply button is pressed.
Matrix processing function eliminateNonZerosOverPivotInUpperTriangularMatrix tried to eliminate ALL non zero values in the upper triangle, even values under a small epsilon. This makes the routine take much more time than it should be. Not considering small values significantly speeds it up, ultimately increasing sketch constraint solving performance.
* Added disc measurements radius, diameter and area.
* [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>
At least for G73, the Z, Q and R parameters seem to be required.
Assuming drill related parameters are required for all drill
operations to err on the safe side.
Fixes#27413
* BIM: initial implementation of sliding door preset
* BIM: fix sliding door context menus
* BIM: limit travel distance
* BIM: increase preset indexes for icons
* BIM: update edit task panel to adapt to sliding doors
* BIM: make rotation/translation data exclusive or
* BIM: remove code duplication for Sliding and -Sliding doors
* BIM: refine travel distance clamping to expose handle
* BIM: make sliding direction independent of geometry direction
* BIM: remove non-visible 2D symbol for now
* BIM: make door leaf wire comment more precise
* BIM: use local coordinates when calculating the start/end points for the sliding track
This PR intruduces a way to dynamicly alias toolbits and adds subtype
for toolbits. Prior to this change, aliases were hardcoded in multiple
locations, making it difficult to maintain and extend. Now, aliases
and the newly subtypes are defined in a single JSON file, which is
loaded at runtime. This allows for easier management and addition of new
aliases or subtypes without modifying the codebase.
Updated the shape system to use a dict format for aliases and subtypes,
improved label formatting, and fixed normalization logic for toolbit
types. Enhanced dropdown display and editor logic to properly handle
subtypes and aliases, including special cases for consecutive capitals.
Users can add shape_aliases.json to the toolbit Shape dirctory allowing
theme to add/remove entries. Adding a "!" in front of a alias or a
subtime removes it from the list.
This PR also introduces the ability for the user to choose tools from
a libary or all tools when adding tools via the Job panel.
src/Mod/CAM/Path/Tool/docobject/ui/docobject.py:
- Added keep_case and preserve_consecutive_caps options to
_get_label_text for improved label formatting
src/Mod/CAM/Path/Tool/shape/__init__.py:
- Refactored alias/subtype loading to support new dict format
- Applied aliases and subtypes to shape classes
src/Mod/CAM/Path/Tool/shape/models/base.py:
- Added subtypes attribute to ToolBitShape
- Updated class lookup to support subtypes
src/Mod/CAM/Path/Tool/toolbit/models/base.py:
- Improved normalization logic for aliases and subtypes in
ToolBit.from_dict
src/Mod/CAM/Path/Tool/toolbit/ui/editor.py:
- Updated editor logic to use subtypes and aliases for dropdowns
- Improved read-only and editable state handling
src/Mod/CAM/Path/Tool/toolbit/ui/typefilter.py:
- Used _get_label_text for dropdown filter display with improved
formatting
src/Mod/CAM/Tools/Shape/shape_aliases.json:
- Converted to new dict format with separate aliases and subtypes
* [ArchWall] Fix Regression: sortSketchWidth only in addon
Regression was introduced when get_width() method uses ArchSketchObject.sortSketchWidth() function in below lines.
https://github.com/FreeCAD/FreeCAD/blob/468269b9a6ea58cd8b0f9d8579b711c530db83b2/src/Mod/BIM/ArchWall.py#L1668-L1673
if not lwidths:
if obj.OverrideWidth:
if obj.Base and obj.Base.isDerivedFrom("Sketcher::SketchObject"):
lwidths = ArchSketchObject.sortSketchWidth(
obj.Base, obj.OverrideWidth, obj.ArchSketchEdges
)
ArchSketchObject.sortSketchWidth() function is not in the FC core ArchSketchObject.py module and this results in error. This function would only exist when the external add-on is present and loaded.
Previously, a try/exception test was used; now hasattr() is used in this fix to test the presence of the required function before it is used.
* [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>
* Sketcher: OVP Fix tab not working when mouse move
* [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>
Use pimpl or move definitions to .cpp files in order to avoid including huge Boost headers in core FreeCAD headers. Due to boost inclusions in a few core headers, boost graph utilities, multi index and predicates headers were included in in a large portion of translation units, without them being actually required. This helps reduce build time of the project.
* BIM: regression test for child object stability during wall debasing
Introduces test_debase_wall_stationary_children to verify that objects
attached to a wall (via Additions or Hosts) retain their global position
when the wall's base is removed and its placement is recalculated.
* BIM: Fix wall debasing to maintain stationary child element positions
Corrects the placement propagation that occurred when Arch.debaseWall()
recalculated the Wall's Placement, causing connected children (Windows,
Additions) to shift their global coordinates.
The fix pins children by capturing their current global placements before
the wall's placement is updated, and immediately restoring those placements
after the wall's transformation is complete.
Fixes: https://github.com/FreeCAD/FreeCAD/issues/27267
* Avoid confusing comment about wall placement in TestArchWall.py
---------
Co-authored-by: Roy-043 <70520633+Roy-043@users.noreply.github.com>
* BIM: extend ArchComponent test suite
Adds several unit tests to TestArchComponent.py to validate the
coordinate system logic and CSG behavior of generic Arch Components.
Included tests cover:
- Double-transformation/displacement bugs when using moved base objects.
- Correct alignment of CSG additions/subtractions in world space.
- Consistency of Vertical and Horizontal area calculations for
rotated components.
- Automatic geometry spreading (arraying) via the Axis property.
- Cleanup behavior ensuring the shape is cleared when the Base
link is removed.
* BIM: fix double displacement bug and area calculation in ArchComponent
Rewrites ArchComponent.Component.execute to resolve placement
conflicts between the Document Object and its internal TopoShape.
Changes:
- Reset base_shape.Placement to Identity immediately after copying
from the source. This strips inherited placements from the Base
object, ensuring the geometry is local before processing.
- Pass the object's placement to processSubShapes. This allows
additions and subtractions to be correctly localized to the
component's local origin.
- Replaces direct Shape assignment with self.applyShape(). This fixes
area calculations by ensuring the AreaCalculator receives the
correct placement context, and enables automatic geometry
spreading via the Axis property.
Fixes: https://github.com/FreeCAD/FreeCAD/issues/24580
* BIM: Refine base validation in ArchComponent to prevent stale shapes
Updates the validation logic in ArchComponent.execute() to correctly
handle the removal of a base object.
Changes:
- The check on self.ensureBase(obj) now explicitly looks for
False. Because ensureBase returns None when no base is present,
the previous logic would return early and leave the old shape
behind.
- This change allows the method to fall through to the shape-clearing
logic, ensuring that unlinking a base object correctly removes its
geometry from the 3D view.
- Added a TODO note to ensureBase() regarding its undocumented
triple-state return (True, False, None) for future cleanup.
* Measurement: Fix: missing tr() wrapping causing build failure
* Swapped tr() with QLatin1String()
* [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>
* Ensure read only Booleans are shown using Disabled Text color
* Make the disabled text color a more significant contrast to enabled
* Ensure correct contrasting color for Axis letters versus background color for both Light and Dark themes
This fixes a difference between Main code and LS3 Code ported during TNP big merge. The Issue generates a crash if FreeCAD is compiled in Debug Mode: #27489.
Enables the user to change the unit of the measurement temporarily to convert to a different unit. This is useful when the user sometimes needs to get a dimension of the model in a different unit than the one it was designed in.
Sweep tests parse a string and translate it back, verifying identical
output. Values cover every threshold band at 10x increments plus a
scientific-notation value in each default band. Tests all 10 schemas.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When a parsed value lands exactly at a threshold boundary (e.g. "1 S/m"
= 1e-9 at threshold 1e-9), floating point rounding could cause the
wrong unit to be selected. Shrink thresholds by a relative epsilon so
boundary values fall through to the next (more natural) unit.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Corrects 12 bugs across Internal and MKS schemas where factors were
wrong, units were assigned to the wrong threshold positions, or
thresholds didn't align with natural unit boundaries.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Assembly: Isolate grounded objects on selection
* [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
* Update ViewProviderAssembly.cpp
* Update ViewProviderAssembly.cpp
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>
Draft_Labels have a unique Placement implementation. A ghost preview therefore cannot be generated in the standard manner. This was missed in #18795 (my bad).
For the import/export use the transparency value of the material property.
Since v1.0 the alpha channel of the diffuse color is used for this but
when changing the transparency in the user interface this alpha channel
won't be adjusted and thus leads to unexpected results.
This fixes issue 18569
* Draft: Fix switchUi method bug
* [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>
Renamed several SVG text element IDs in tool shape files that did not
match the expected naming conventions used. This ensures that the tool
parameters are correctly recognized and utilized by the Tool library
editor.
src/Mod/CAM/Tools/Shape/bullnose.svg:
- Changed text element id from "torus_radius" to "corner_radius"
src/Mod/CAM/Tools/Shape/radius.svg:
- Changed text element id from "cutting_edge_height-7" to
"cutting_radius"
- Changed text element id from "diameter-9" to "tip_diameter"
src/Mod/CAM/Tools/Shape/svg_source/bullnose.svg:
- Changed text element id from "torus_radius" to "corner_radius"
src/Mod/CAM/Tools/Shape/svg_source/radius.svg:
- Changed text element id from "cutting_edge_height-7" to
"cutting_radius"
- Changed text element id from "diameter-9" to "tip_diameter"
Add arithmetic operators (+, -, *, /, unary -) to Value, enabling
element-wise operations on tuples and scalar broadcast with numerics.
Tuple addition/subtraction uses union semantics: named elements match
by name, unnamed elements match positionally, and unmatched elements
pass through. BinaryOp and UnaryOp now delegate to these Value operators.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add MemberAccess AST node and postfix `.member` parsing to support
extracting individual elements from tuple-valued parameters, e.g.
`@ButtonBorderThickness.left` or `@Grays.0`.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move Numeric, Tuple, Value, valueTypeName, ArgumentParser, and ParamDef
into their own Value.h/.cpp files. ParameterManager.h now includes
Value.h and keeps only parameter sources and the manager itself.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds ArgumentParser class that resolves mixed positional and named
arguments against a declared function signature (Python-style).
Includes Tuple::get<T>(name) for type-checked access with
user-friendly error messages. Refactors lighten/darken/blend to use it.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace the separate argument parsing in parseFunctionCall() with a
call to parseTuple(), unifying the two comma-separated-expression
parsing paths. FunctionCall now stores a TupleLiteral instead of
a vector of expressions, and evaluates it into a Tuple value that
functions access via at()/find().
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Test cases cover unnamed, named, and mixed tuples, single named
elements, nested tuples, expressions and mixed types in elements,
toString roundtrip, Value::holds/get accessors, Tuple::at/find/size,
error handling, and backward compatibility of grouped expressions.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add TupleLiteral AST node and parser support for tuple syntax using
parentheses with comma-separated elements: (val1, val2) for unnamed
tuples, (name: val1, val2) for named elements.
Disambiguation with grouped expressions in parseFactor():
- `(identifier:` lookahead → tuple
- expression followed by `,` → tuple
- expression followed by `)` → grouped expression (backward compatible)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add a tuple value type to the StyleParameters system, allowing related
values to be grouped into a single parameter with optional named fields.
Tuple is stored inline in the Value variant. The circular dependency
(Value contains Tuple, Tuple elements contain Value) is broken by
storing element values as shared_ptr<const Value> inside Tuple::Element.
Generic holds<T>() and get<T>() template methods are added to Value
for uniform type-checked access to all variant alternatives.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Add Copper Alloys to Material-Metals
Added a set of Copper Alloys presented in Application Data Sheet
'cda144-8-mechanical-low-temperature.pdf, Nov1974'
Permission and Credit to the 'Copper Distributor's Association (CDA)'
These cards follow values for 295°K
Colours approximate values found by general search of images and
descriptions found on the internet and use FreeCAD's appearances.
* Add Copper Alloy general/generic information
This additional information appears as general info not affected by
anneal or cold drawn or aging factors.
Information found from pages C10200, C12200, C15000, C22000, C23000,
C44300, C46400, C51000, C61400, C64700, C65500, C70600, C71500, C95500
Also followed suggestions of adding tagging and description mentioned
in pull request.
* Add Copper Alloy source URL
Added the URL for the source Application Data Sheet
'cda144-8-mechanical-low-temperature.pdf, Nov1974'
This pdf is hosted by the 'Copper Distributor's Association (CDA)'
Here is the source URL for this pull request in case it's needed:
https://github.com/FreeCAD/FreeCAD/pull/25832
* Add Copper Alloy UltimateStrain for 102,122a,122b at 295°K
102=2.8%, 122a=39.7%, 122b=1.46%
* Add Copper Alloy UltimateStrain for remaining cards 150...955 at 295°K
105=4.13%, 220=41.5%, 230=40.4%, 443=82%, 464=31.8%, 510=3.6%, 614=27%
647=9.9%, 655=10.4%, 706=28.4%, 715=39.9%, 955=10.6%.
Removed spaces between IACS = nn%, so that it all stays on same line.
Added C95500 compressive MPa.
Added C64700 Si and IACS ranges.
Also looked at 'KindOfMaterial' for Steel and made similar edits based
on Table 2 info shown in brackets () to try keep a bit of consistency.
* Fix Ultimate Strain Description and Units
Ultimate Strain is the maximum stretch you can do to a material before it
gives up. This is associated with Ultimate Tensile Strength, which is the
maximum stress you can apply before the material starts to fail, elongate
and eventually fracture.
Units are of the type ΔL/L, such as, stretched 0.10in per 1.0in (10%), or
stretched 0.15mm per 1.0mm (15%). To avoid confusion, use 0.1 or 0.15 and
avoid using 10 as for 10% or 15 as with 15%, and just call it a fraction.
* Add Copper Alloy Elongation, Reduction of Area, Yield Strain, Toughness
Impact Charpy and Notch Tensile Strength are both considered as Toughness
There is currently no use for these in FreeCAD, but maybe a future use as
these are part of the Table 2 and better to add them now vs forget adding
them later. The Charpy test is a fast cost-effective standardized method,
and there are other more sophisticated impact tests that can be "better".
There are other tests than the notch tensile strength test, but it's also
a simple, fast, cost-effective method to create fracture toughness data.
While adding 'Elongation' and 'Reduction of Area' both these are referred
to as percentages (preferred over fraction), it seemed best to change the
'Ultimate Strain' to percentages too for consistency even though this has
was referred to as fraction or percentage when searching for definitions.
Added Yield Strain, probably not important now because the elastic region
is pretty small, but with smart metals that can do up to 5% bends then it
seems something worth adding it for that category of future metal alloys.
* Add Copper Alloy Isotropic, Linear, Toughness Temperature Arrays
* Add Copper Alloy Elastic & Toughness arrays and reduce model wordiness
Reduced wordiness of array models by cutting-out Metal and Temperature
as these are somewhat redundant words.
Added remaining ElasticProperties and PlasticTriaxialProperties.
* Add Copper Alloy Linear Elastic Temperature Arrays
Moved Elongation and ReductionOfArea after YieldStrain/Strength and added
FractureStrength so these are grouped together on the cards since they're
all related (Note: Material viewer resorts these alphabetically).
Linear Elastic arrays are set in the order of strain/strength for Tensile
then strain/strength for Yield, and then Elongation/FractureStrength, and
then ReductionOfArea.
Reviewed pdf again and corrected a few errors missed/made earlier.
- I'm not familiar with absolutely all usages of expressions - this is
intended more as a starting point to make it easy to add more
- The test captures *current* behaviour, please don't assume that
everything it tests is *correct* behaviour
Fix some weird quirks before adding new tests:
- The whole file has clang format off, this feels unnecessary, localize
it to where it's important
- Put the code inside a nested test namespace within the production
namespace, this is generally good practice rather than putting it in
the global namespace, and it means we don't have to explicitly namespace
methods that are directly under test
- Rename variables to camelCase, which afaict is closer to 'normal' in
freecad cpp
- Remove the usage of arrays. Maintaining manual array sizes is
annoying. Just use initializer lists here as they are all constants.
- I have *not* renamed the snake_case methods, as I feel that it
destroys too much of the git history for too little benefit
- Removes many/most of the copy().release() from the last commit
- Still some .release() in the simplify functions now
- It doesn't work to rename simplify and turn it into a protected
method, because it's called recursively within the tree
- We need copy().release() on many of these calls because nodes in the
tree call 'copy' explicitly. It's not really different to the code
that's there now, but it's not pretty either. Some of these will go
away in the upcoming commit
- Most of the usages of 'release' are temporary here, but a few will
likely need to stay. In these cases, the existing behaviour is
retained. To fix all usages, smart pointers would need to be used all
throughout the tree
- The freecad_cast looks awkward now. I haven't added a new version that
works with smart pointers because it's not clear what the right
ownership semantics would be. Make the caller be explicit for now.
- Start at ScanResult, as starting higher makes it easy to have memory
issues.
- There are multiple memory leaks (at least in tests, but possibly in
production code too) from using raw pointers in the public interface
here. Fix these before adding more tests.
- Starts at ScanResult
- The bison changes were applied manually, as I don't think that it's
pixified and running my local version showed many changes.
- I've chosen not to pimplify Expression, but only because it would be
such a significant change for not so much value.
This change was introduced in 80a35a8765 (#24617) and
reverted without explanation in 21a597a85e (#27202).
I assume it was reverted by mistake.
Note that for dynapath_4060_post.py, the original help text did not match the postamble,
illustrating the need to ensure the actual value matches the help text.
Do not directly pass getNameInDocument() to the ostream as this will
set the badbit in case it returns nullptr. As a result no further
output is written to the stream and leads to loss of data.
Instead the returned C string is stored in a local variable and in case
it's nullptr an empty string is passed to the ostream.
At the end of the function writeObjects() it's checked whether the
failbit or badbit is set. If yes an error message is printed and the
failbit or badbit are cleared.
This is supposed to fix the issue 18044.
In case this fix is not sufficient it can be also check for every
object inside writeObjectData()
* Do not raise an exception when saving a document and an object has
'freeze' status because this breaks the project file and may lead
to loss of data.
* Make 'freeze' state persistent
* When toggling 'freeze' status only work directly on the selection.
Do not use in-list or out-list of an object because this makes it
quite inflexible and leads to unpredictable behaviour.
This fixes issue with saving frozen files described in 18806.
This commit comments out javascript for doxygen that does not work
anymore or is unneeded in newer versions. The code is left in for later
attempts to revitalize this functionality, most notable the search
function.
* various bug fixes and updates
* [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>
* BIM: remove LibraryWebSearch option from BIM_Library as it required the Web WB
Removed the 'checkWebSearch' checkbox and updated tooltip text formatting.
* BIM: remove LibraryWebSearch option from BIM_Library as it required the Web WB
* Restore tooltip
* Assembly: Insert flexible assembly grounds the correct part
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Assembly: Migrate ObjectToGround to PropertyLinkGlobal to support assembly links
* Update JointObject.py
* Assembly: ViewProviderAssembly fix assembly link deletion issue
* Assembly: ViewProviderAssembly: make sure no duplicates in canDelete
* Assembly CommandInsertLink fix typo
* [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>
* BIM: add Wall options task box to ArchWall's edit task panel
* BIM: update Align property live on the task box
* BIM: make wall options cancellable
* BIM: make the Component task box actions reversible, in particular debasing a wall
* 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>
* CI: upgrade Ubuntu native build to 24.04
* CI: reenable Ubuntu native build
* CI: abandon PySide6 pip approach, try KDE Neon repos
* BIM: fix mistake in casting return value
* BIM: add wall label to better identify transaction in the Undo stack
* BIM: remove superfluous statement
* BIM: add explanatory comment about additional transaction pending flag
* BIM: Refactor Wall transaction logic to use explicit argument passing
This replaces the `Proxy.InTransaction` flag mechanism with a cleaner
transaction architecture based on explicit argument passing.
The motivation for managing the transaction mechanism is that
previously, removing a Wall's base object via the Task Panel triggered
`debaseWall`, which opened and committed its own transaction
immediately. This nested commit finalized the document state
prematurely, rendering the Task Panel's "Cancel" button ineffective.
The Task Panel now owns the transaction lifecycle for the editing
session. It propagates a `manage_transaction=False` flag down to the
logic layer, preventing nested transactions from committing prematurely.
Key changes:
- Arch.py: `debaseWall` now accepts `manage_transaction` (default True).
Setting it to False allows the Task Panel to disable the nested
transaction and include the debasing operation into its own
transaction context instead.
- ArchComponent.py:
- `ComponentTaskPanel` now manages the transaction lifecycle (Open in
init, Commit in accept, Abort in reject).
- `ComponentTaskPanel.removeElement` now passes
`manage_transaction=False` when calling the object's
`handleComponentRemoval` proxy method.
- Updated `Component.handleComponentRemoval` signature to accept the
`manage_transaction` argument.
- ArchWall.py:
- Updated `_Wall.handleComponentRemoval` to pass the
`manage_transaction` flag to `debaseWall`.
- Cleaned up `WallTaskPanel` by removing the deprecated
`InTransaction` logic and redundant overrides.
* BIM: provide immediate visual feedback on additions and subtractions
* BIM: remove low-level API transaction management
* BIM: Refactor transaction management in ComponentTaskPanel
The C++ GUI layer implicitly manages the transaction lifecycle when
entering and exiting edit mode.
Explicitly opening a transaction in init and committing in accept() is
redundant, as the backend establishes the transaction name and performs
the final commit during the resetEdit() cleanup phase.
The reject() method retains an explicit abortTransaction() call to
signal a rollback, which prevents the backend from committing session
changes by default.
Docstrings are added to clarify this implicit interaction between the
Python UI and the C++ document management logic.
* Wall Options in title case
* QtGui.QApplication.translate -> translate
---------
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>
* BIM: add test for horizontal area of tilted cylinders
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fix typos and use makeComponent instead of makeStructure
* Change makeComponent back to makeStructure
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
The icon logic in _ViewProviderWall.getIcon previously switched to the
assembly icon for any wall without a Base that contained Additions. This
caused an unexpected icon change when a wall was debased, as it still
retains a parametric body defined by its Length property.
Update the logic to only show the assembly icon if the wall has no Base,
has Additions, and its Length is zero. This ensures that baseless walls
driven by their own dimensions maintain the standard wall icon.
* Base: Add TimeTracker
This adds TimeTracker utility that can be used to orchestrate code
with time measurements in an easy way and detect performance issues.
* Update src/Base/TimeInfo.h
Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>
---------
Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>
When a child (e.g. a Wall) of an ArchBuildingPart (e.g. of a Level)
had both 'Move With Host' and 'Move Base' enabled, it failed to move
the base (e.g. Line) of the child, and only displaced the child
itself (effectively ignoring the 'Move Base' setting).
Example project structure:
Level
|
+- Wall ('Move With Host' = true, 'Move Base' = true)
|
+- (base of Wall) Line
Export mesh object names as 'name' attribute in 3MF files according to
the 3MF specification. This allows downstream tools to identify objects
by their original FreeCAD names.
Changes:
- Moved Exporter::xmlEscape() to Base XMLTools::escapeXml() for shared XML entity escaping
- Update Writer3MF::AddMesh() to accept and output object names with default "" where no attribute will be added
- Updated all codepaths leading to 3mf exports to include the object name
Since we are linking to boost anyway, use boost function for case
insensitive string compare. While there, make affected methods accept
std::string arguments, which simplifies code a bit.
It can happen that TransactionFactory::createTransaction() fails to create a transaction object because an unsuitable type is passed
(like BadType) and returns a null pointer.
The calling instances (Transaction::addObjectChange, Transaction::addObjectDel, Transaction::addObjectNew, Transaction::addOrRemoveProperty)
do not check for a null pointer and thus cause a segmentation fault by dereferencing it.
To fix the issue change the above methods to explicitly handle a null pointer.
This fixes issue 21095.
Note: In this case it's caused by the class ViewProviderFace which on purpose isn't added to the type system so that its type will be BadType.
If the property is added to a view provider then in debug mode this will
cause a crash while in release mode this will cause undefined behaviour
because of a static_cast.
To fix crashes remove the assert() and replace the static_cast with
freecad_cast.
Put the reading of each expression of an object into a try/catch block. This is to avoid that all expressions of an object may be lost.
This mitigates the issue 19866
- FileOptionsDialog is only used in the 'save screenshot / save image'
codepath, and currently it doesn't set a directory to it defaults to
process CWD, which is surely not what the user wants.
- The load image codepath uses a custom QFileDialog instead of the
helper code in FileDialog, there doesn't seem to be a great reason for
this, although the helper doesn't have support for mime types it seems.
- I haven't changed the dialogs to 'set/store' the working directory. I'm
not sure this is desired as this isn't a 'normal' save/load operation.
- It would be ideal to remove the FileOptionsDialog in future. The
extended functionality could be turned into a separate dialog which
opens before or after the file chooser. This would allow native dialogs
to be used and would unify the code paths for file selection.
- Further, it would be nice to just merge at least the load image into
the existing import/open option, and to put 'save image' next to
'export', but those changes may be much more time consuming.
For now I've kept it simple. Let's see what others think.
* Menu text "Align Horizontal/Vertical Chain Dimensions" to match "Align Oblique Chain Dimensions"
* Menu text "Centerline Between 2 Faces" is not correct.
* Update button text "Replace References With Current Selection" to title case
* Change task panel title from 'Add offset vertex' to 'Offset Vertex'
* Correct text casing for 'Pick points' button
* Correct text casing for 'Pick points' and 'Edit points'
* Fix capitalization of task panel section title
* Correct text case for 'Escape Picking' button
* Update texts for centerline buttons to match menu texts
This commit addresses two regressions in the MultiCommon feature:
1. Computation Logic: Fixed an issue where the common operation was
calculated as the intersection of the first shape with the union of
the rest (the default behavior of makeElementBoolean). It now
correctly computes the intersection of all shapes sequentially.
2. Compound Handling: Added logic to expand a single compound input
into its constituent shapes. Previously, a compound was treated
as a single entity, leading to incorrect intersection results.
To maintain backward compatibility, a hidden 'Behavior' property is
introduced. This ensures that documents created in FreeCAD 1.0, which
rely on the previous behavior, continue to render as originally
intended while new objects use the corrected logic.
* Part: Fix mirror() regression with non-identity Placement
The makeElementMirror() function incorrectly extracted and pre-multiplied
the shape's Location with the mirror transform. Since BRepBuilderAPI_Transform
already handles shapes with Location correctly, this resulted in the placement
being applied twice, producing incorrect results for shapes with non-identity
Placement.
Fixes#20834
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Part: Add regression test for mirror() with Placement
Adds testTopoShapeMirrorWithPlacement to verify that mirror() produces
identical results regardless of whether the shape is positioned via
direct coordinates or via Placement.
This test would have caught the bug fixed in the previous commit where
shapes with non-identity Placement produced incorrect mirror results.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* Fix regression test for mirror with Placement
The test was incorrectly trying to create equivalent boxes using
different methods that don't actually produce the same geometry.
Part.makeBox with a direction vector is not equivalent to setting
a Placement with rotation.
Fixed to use the correct approach that demonstrates the actual bug:
- Method 1: Box with geometry at (0,30,0), identity Placement
- Method 2: Box with geometry at origin, moved via Placement
Both should produce identical mirror results, which they now do
with the makeElementMirror() fix.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Timothy Miller <theosib@zeromark.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Implement the methods Save() and Restore() for PropertyIntegerConstraint and PropertyFloatConstraint. Handle also the case of a user-defined ranges.
This fixes https://github.com/FreeCAD/FreeCAD/issues/24571.
Hint: For PropertyQuantityConstraint this is not doable because it doesn't support user-defined ranges
* cam: attempt to fix issue #26652 ie. fix issue with state of recompute button for tool bit
* add unit test for issue #26652
* run precommit
* relocate `purgeTouched()` call to end of `_update_visual_representation` function
* Assembly: Change Joint References to remove cyclic dependency.
* Update JointObject.py
* Update TestCore.py
* Update JointObject.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update AssemblyUtils.cpp
* Update UtilsAssembly.py
* Update JointObject.py
* small fix for link groups
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* PartDesign: Add interactive gizmo for draft operation
* [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>
Cache object property list in expression completer, so it is not rebuilt for every requested index. This helps with performance when an object has a large number of properties.
* Added support for cylindrical surfaces
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Removed unnessecary sign
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Reverted change
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Make sure to use the active default values for preamble and postamble in the help text,
and provide the current default values as the default in the add_argument().
The only exception is uccnc_post.py, where the real default value depend on the use of
--no-comments, and sending the default argument to add_argument() would change behaviour.
This change was inspired by the changes done to fix (#20792) in
d84d9c9bd1.
Fix "Activating a body in a part in an assembly deactivates the assembly and activate the part"
Fix "A manually deactivated assembly is still restoring later"
* Gui: Fix property checkbox regression
* Update PropertyItemDelegate.cpp
* Gui: property checkbox: toggle with enter when it has focus
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Fixes#26965
`self.snapObjectIndex` should be increased if the object under the cursor is not 'snappable'. This is the same principle as is used in the `cycleSnapObject` function.
Updated makeShellFromUpToShape to accept the direction vector by reference.
This allows the method to reverse the direction internally if required
to successfully reach the target face, fixing cases where the extrusion
would otherwise fail or go the wrong way.
Note: While passing the direction as a non-const reference is a quick
fix for this regression, it is acknowledged as non-ideal and should
be considered for future refactoring.
This commit registers last rendered shape within the ViewProvider for
Part objects and short-circuits the visuals recomputed if shape did not
change.
Co-Authored-By: Kacper Donat <kadet1090@gmail.com>
* BIM: Add tests for ArchComponent.AreaCalculator.isFaceVertical
* BIM: test new area calculation fallback case
* BIM: add test for composite complex surface vertical area calculation
The linter report 'private field 'decimals' is not used'. The
getDecimals() method return pack.defDecimals, which was also
used to set the value of the decimals variable in the initializer,
so the decimals variable is redundant.
Introduced new toolbit and shape models for tapered ball nose tools,
including schema, summary, and integration into CMake and module
imports. Added corresponding SVG and FCStd files to resources.
Updated SVGs so end markers (arrows) render correctly in Qt by
converting markers to paths. Kept a source SVG with markers as
strokes (not paths) for future editing and updates.
Reworked the ToolBitEditor UI to display the toolbit to the right of the
toolbit properties, improving usability. Shrunk the overall height of
the editor window to better fit typical screen sizes.
src/Mod/CAM/CMakeLists.txt:
- Registered new taperedballnose toolbit and shape models and resources
- Added updated SVGs and source SVGs for marker compatibility
src/Mod/CAM/Path/Tool/shape/__init__.py:
- Imported ToolBitShapeTaperedBallNose and added to __all__
src/Mod/CAM/Path/Tool/shape/models/taperedballnose.py:
- Added ToolBitShapeTaperedBallNose class with schema and label
src/Mod/CAM/Path/Tool/toolbit/__init__.py:
- Imported ToolBitTaperedBallNose and added to __all__
src/Mod/CAM/Path/Tool/toolbit/models/taperedballnose.py:
- Added ToolBitTaperedBallNose class with summary and integration
Tools/Shape/taperedballnose.svg, Tools/Shape/taperedballnose.fcstd:
- Added new SVG and FCStd for tapered ball nose
- Updated SVGs for correct marker rendering in Qt
- Kept editable source SVGs with markers as strokes for future updates
d885ae35147 {doc} Update CHANGELOG for 3.3.0
9e7c0a25e4c {cmake} Update version to 3.3.0
8b668f19380 {doc} Update CHANGELOG
dcdda358b0f {doc} Add MicMac to README
5fb956155c7 Replace codecvt_utf8_utf16(deprecatred in C++17) with WIN32 API if C++>=17
a99cbb9ac82 {ci} Update actions/checkout to v5
23a37530095 {ci} Fix CI warnings
04a913cc35e {ci, doc} Fix clang -documentation warnings (#327)
7e3079b9a35 {ci} Make Windows CI working again (#325)
bab1d8b2350 {doc} Update CHANGELOG
git-subtree-dir: src/3rdParty/libE57Format
git-subtree-split: d885ae35147dabd0ad9f6a85e46538b27b1b701c
Corrected CMakeLists.txt to ensure Path/Machine/ui/editor Python files
are installed and packaged properly. The previous variable name typo
prevented these files from being included in AppImage and install
targets, though local builds worked due to build directory copying.
This resolves missing module errors on some systems and in AppImage.
src/Mod/CAM/CMakeLists.txt:
- Fixed INSTALL command to use the correct
PathPythonMachineUiEditor_SRCS variable for Path/Machine/ui/editor
- Ensured all relevant Python files are included in both build and
install steps
* CAM: Drilling - Fix regression after #26584
* CAM: Linking generator - Fix machinestate handling
Fix linking generator for drilling
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Add remaining logic to terminate canned cycles appropriately (#2)
* sorted heights
* Refactor buildPostList
Introduces early tool prep to the buildpostables.
Allows emitting a T command early to give tool changer
time to index the tool before the M6 tool change command is emitted.
updates unit testing for this use case
Not implemented in postprocessors yet.
fix
* Helper and tests for terminating canned cycles
fix cycle termination
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* CAM: setFeedRate now aware of drilling semantics (#3)
Remove retract plane property
machinestate properly handling z position
* next bugs (#4)
* setFeedRate now aware of drilling semantics
Remove retract plane property
machinestate properly handling z position
* unnecessary import.
Improved linking
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fix rendering of canned cycles in G99 mode (#5)
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* fix for collision (#6)
* collision bug fix
* fix local variable
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: sliptonic <shopinthewoods@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* [ArchWall] Fix: Better Info 0 Width Or 0 Height
Fix#25338
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* [ArchWall] (Update) Fix: Better Info 0 Width Or 0 Height
Update - Following discussion at https://github.com/FreeCAD/FreeCAD/pull/25878Fix#25338
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* [ArchWall] (Update 2) Fix: Better Info 0 Width Or 0 Height
Update - Following discussion at #25878
Update 2 - Add translation
Fix#25338
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* [ArchWall] (Update 3) Fix: Better Info 0 Width Or 0 Height
Update - Following discussion at #25878
Update 2 - Add translation
Update 3 - Follow comment on https://github.com/FreeCAD/FreeCAD/pull/25878#issuecomment-3724698834
- Test of shape further relocated to after self.applyShape()
Fix#25338
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Improve warning message for ArchWall object
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Roy-043 <70520633+Roy-043@users.noreply.github.com>
* 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.
* 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>
* 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>
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
* 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>
App::DocumentObject had docstrings both in the cpp file and in the
header file. All documentation has been moved to the header file. In
cases where documentation existed in both the header and cpp file, the
documentation has been reconciled.
* 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>
* 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>
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.
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.
- 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.
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
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.
* 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>
* 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.
* 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>
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
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.
* 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>
* 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>
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.
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.
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);
| ^
```
* 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>
* 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>
* 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>
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.
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.
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.
* [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.
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.
* [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>
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.
* 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>
- 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
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
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.
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
* 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`.
* 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>
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
* 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.
* 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>
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.
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.
Change `ViewProviderPart` to inherit from `ViewProviderGeometryObject`,
giving Part containers the Selectable property. This allows recursive
selectability checks to respect the entire container hierarchy.
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.
- starts finishing pass farther down, to avoid looping back for it
This now has all the features to address #19768, but I think I want to
pick out just what is required for that PR
- rewrote area calculation using floats; it works (compared against
Clipper as ground truth)
- rewrote boundary approach code
- rewrote min cut/min engage code
# 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)
# 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)
> Bleeding edge FreeCAD development builds for testing bugfixes, regressions, and recently implemented features. Do not use in a production environment.
@@ -62,7 +62,9 @@ The FreeCAD Contribution Process is expressed here with the following specific g
1. the PR description MUST contain proper attribution as the first line, for example: "This is work of XYZ cherry-picked from <link>";
2. all commits MUST have proper authorship, i.e. be authored by the original author and committed by the author of the PR;
3. if changes to cherry-picked commits are necessary they SHOULD be done as follow-up commits. If it is not possible to do so, then the modified commits MUST contain a `Co-Authored-By` trailer in their commit message.
14.A “Valid PR” is one which satisfies the above requirements.
14.Contributions must meet existing quality standards. Raw AI output is not accepted under any circumstances. AI may be used only as an assistive tool; in all cases, the resulting content must be reviewed, validated, and justifiable by the contributor. The contributor should be able to explain design and code decisions, answer reviewers’ questions, and ensure that AI use does not waste reviewers’ time during review. That being said, the use of AI is not recommended under any circumstances or in any manner.
15. The contributor provides reasonable assurance that the contribution does not infringe third-party copyrights or license terms.
16. A “Valid PR” is one which satisfies the above requirements.
* 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
structEntity:std::enable_shared_from_this<Entity>
{
intvalue=42;
voidprint()
{
std::cout<<"print called, num = "<<value<<std::endl;
}
std::function<void()>print_later()
{
// ! weak this idiom here !
autoweak_this=weak_from_this();
return[weak_this]{
if(autoshared_this=weak_this.lock())
{
shared_this->print();
}
};
}
};
intmain()
{
autoentity=std::make_shared<Entity>();
autoprint=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>
usingVoidSignal=fastsignals::signal<void()>;
usingVoidSlot=VoidSignal::slot_type;
structEntity:std::enable_shared_from_this<Entity>
{
intvalue=42;
VoidSlotget_print_slot()
{
// Here fastsignals::bind_weak() used instead of std::bind.
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::mapCreateMyMap();
```
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.
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([]{
returntrue;
});
```
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:
TEST_CASE("Can connect a few slots and emit","[signal]")
{
signal<void(int)>valueChanged;
intvalue1=0;
intvalue2=0;
valueChanged.connect([&value1](intvalue){
value1=value;
});
valueChanged.connect([&value2](intvalue){
value2=value;
});
REQUIRE(value1==0);
REQUIRE(value2==0);
valueChanged(10);
REQUIRE(value1==10);
REQUIRE(value2==10);
}
TEST_CASE("Can safely pass rvalues","[signal]")
{
conststd::stringexpected="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::stringpassedValue=expected;
signal<void(std::string)>valueChanged;
std::stringvalue1;
std::stringvalue2;
valueChanged.connect([&value1](std::stringvalue){
value1=value;
});
valueChanged.connect([&value2](std::stringvalue){
value2=value;
});
valueChanged(std::move(passedValue));
REQUIRE(value1==expected);
REQUIRE(value2==expected);
}
TEST_CASE("Can pass mutable ref","[signal]")
{
conststd::stringexpected="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.";
All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
@@ -14,10 +14,20 @@ All notable changes to this project will be documented in this file. The format
### Fixed
-{cmake} Added missing include for GNUInstallDirs ([#315](https://github.com/asmaloney/libE57Format/pull/315)) (Thanks Adrian!)
-Fix clang 17 warnings about `@throw` documentation. ([#327](https://github.com/asmaloney/libE57Format/pull/327))
- Fix MSVC C++17 deprecation of `codecvt_utf8_utf16`; replaced with `MultiByteToWideChar` if compiling with C++ >= 17. ([#326](https://github.com/asmaloney/libE57Format/pull/326)) (Thanks Christophe!)
- {ci} Fix some CI warnings and update actions. ([#328](https://github.com/asmaloney/libE57Format/pull/328))
- {ci} Fix GitHub CI for Windows. ([#325](https://github.com/asmaloney/libE57Format/pull/325)) (Thanks Christophe!)
- {cmake} Add missing include for GNUInstallDirs ([#315](https://github.com/asmaloney/libE57Format/pull/315)) (Thanks Adrian!)
If you built without testing on, the cmake files were not installed to the correct location.
- {standard conformance} Don't try to fill in intensity limits when using the simple API. They are for the limits that the sensor can produce, not the limits of the data (8.4.19).
@@ -106,6 +106,7 @@ This _Simple API_ has evolved since this original port to fix some problems and
These projects use hard forks of libE57Format:
- [FreeCAD](https://github.com/FreeCAD/FreeCAD)
- [MicMac](https://github.com/micmacIGN/micmac)
- [PDAL](https://github.com/PDAL/PDAL)
There are also many commercial products using libE57Format. If any of them would like to sponsor the project and be listed here, please <a href="mailto:asmaloney@gmail.com?subject=libE57Format Sponsorship">contact Andy</a>.
@param [in] data3D Completed header which indicates the fields we are using
@throw ::ErrorValueOutOfBounds
@throw ::ErrorInvalidNodeType
@throw ::ErrorValueOutOfBounds (n/c)
@throw ::ErrorInvalidNodeType (n/c)
*/
explicitData3DPointsData_t(e57::Data3D&data3D);
Some files were not shown because too many files have changed in this diff
Show More
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.