Skip to content

Commit a36eede

Browse files
authored
Merge branch 'FreeCAD:main' into main
2 parents b50e923 + 8e0bf19 commit a36eede

File tree

237 files changed

+8142
-2710
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

237 files changed

+8142
-2710
lines changed

.clang-tidy

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
Checks: 'clang-diagnostic-*,clang-analyzer-*,boost-*,bugprone-*,
33
performance-*,readability-*,portability-*,modernize-*,cppcoreguidelines-*,google-explicit-constructor,
4-
concurrency-*,-modernize-use-trailing-return-type, -modernize-use-nodiscard,
4+
concurrency-*,-modernize-use-trailing-return-type, -modernize-use-nodiscard,-readability-identifier-length,
55
-readability-redundant-access-specifiers,-readability-qualified-auto,
66
-cppcoreguidelines-avoid-non-const-global-variables,-cppcoreguidelines-owning-memory,
77
-readability-convert-member-functions-to-static,-bugprone-easily-swappable-parameters,
@@ -150,8 +150,6 @@ CheckOptions:
150150
value: '0'
151151
- key: concurrency-mt-unsafe.FunctionSet
152152
value: any
153-
- key: readability-identifier-length.IgnoredExceptionVariableNames
154-
value: '^[e]$'
155153
- key: google-readability-braces-around-statements.ShortStatementLines
156154
value: '1'
157155
- key: bugprone-reserved-identifier.AllowedIdentifiers

.github/problemMatcher/gcc.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"__comment": "Taken from vscode-cpptools's Extension/package.json gcc rule",
3+
"problemMatcher": [
4+
{
5+
"owner": "gcc-problem-matcher",
6+
"pattern": [
7+
{
8+
"regexp": "^(.*):(\\d+):(\\d+):\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$",
9+
"file": 1,
10+
"line": 2,
11+
"column": 3,
12+
"severity": 4,
13+
"message": 5
14+
}
15+
]
16+
}
17+
]
18+
}

.github/problemMatcher/msvc.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"__comment": "Taken from vscode's vs/workbench/contrib/tasks/common/problemMatcher.ts msCompile rule",
3+
"problemMatcher": [
4+
{
5+
"owner": "msvc-problem-matcher",
6+
"pattern": [
7+
{
8+
"regexp": "^(?:\\s+\\d+\\>)?([^\\s].*)\\((\\d+),?(\\d+)?(?:,\\d+,\\d+)?\\)\\s*:\\s+(error|warning|info)\\s+(\\w{1,2}\\d+)\\s*:\\s*(.*)$",
9+
"file": 1,
10+
"line": 2,
11+
"column": 3,
12+
"severity": 4,
13+
"code": 5,
14+
"message": 6
15+
}
16+
]
17+
}
18+
]
19+
}

.github/workflows/sub_buildPixi.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,21 @@ jobs:
8383
- name: Checkout
8484
uses: actions/checkout@v2
8585

86+
- name: Add GCC Problem Matcher
87+
if: runner.os == 'Linux'
88+
run: |
89+
echo "::add-matcher::${{ runner.workspace }}/FreeCAD/.github/problemMatcher/gcc.json"
90+
91+
- name: Add Clang Problem Matcher
92+
if: runner.os == 'macOS'
93+
run: |
94+
echo "::add-matcher::${{ runner.workspace }}/FreeCAD/.github/problemMatcher/clang.json"
95+
96+
- name: Add MSVC++ Problem Matcher
97+
if: runner.os == 'Windows'
98+
run: |
99+
echo "::add-matcher::${{ runner.workspace }}/FreeCAD/.github/problemMatcher/msvc.json"
100+
86101
- name: Make needed directories, files and initializations
87102
id: Init
88103
run: |

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,6 @@ repos:
6767
- id: black
6868
args: ['--line-length', '100']
6969
- repo: https://github.com/pre-commit/mirrors-clang-format
70-
rev: 7d85583be209cb547946c82fbe51f4bc5dd1d017 # frozen: v18.1.8
70+
rev: fed9a1f62c22af0bc846a260ebfeb0844368fd93 # frozen: v19.1.4
7171
hooks:
7272
- id: clang-format

cMake/FreeCAD_Helpers/InitializeFreeCADBuildOptions.cmake

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ macro(InitializeFreeCADBuildOptions)
169169

170170
if(MSVC)
171171
option(BUILD_FEM_NETGEN "Build the FreeCAD FEM module with the NETGEN mesher" ON)
172-
option(FREECAD_USE_PCL "Build the features that use PCL libs" OFF) # 3/5/2021 current LibPack uses non-C++17 FLANN
172+
option(FREECAD_USE_PCL "Build the features that use PCL libs" OFF)
173173
endif(MSVC)
174174
if(NOT MSVC)
175175
option(BUILD_FEM_NETGEN "Build the FreeCAD FEM module with the NETGEN mesher" OFF)
@@ -178,7 +178,10 @@ macro(InitializeFreeCADBuildOptions)
178178

179179
# if this is set override some options
180180
if (FREECAD_BUILD_DEBIAN)
181-
set(FREECAD_USE_EXTERNAL_ZIPIOS ON )
181+
# Disable it until the upstream package has been fixed. See
182+
# https://github.com/FreeCAD/FreeCAD/issues/13676#issuecomment-2539978468
183+
# https://github.com/FreeCAD/FreeCAD/issues/13676#issuecomment-2541513308
184+
set(FREECAD_USE_EXTERNAL_ZIPIOS OFF )
182185
# A Debian package for SMESH doesn't exist
183186
#set(FREECAD_USE_EXTERNAL_SMESH ON )
184187
endif (FREECAD_BUILD_DEBIAN)

src/App/Application.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2060,6 +2060,7 @@ void Application::initTypes()
20602060
App::PropertyElectricCharge ::init();
20612061
App::PropertyElectricCurrent ::init();
20622062
App::PropertyElectricPotential ::init();
2063+
App::PropertyElectromagneticPotential ::init();
20632064
App::PropertyFrequency ::init();
20642065
App::PropertyForce ::init();
20652066
App::PropertyHeatFlux ::init();

src/App/Datums.cpp

Lines changed: 66 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
/***************************************************************************
2-
* Copyright (c) 2015 Stefan Tröger <[email protected]> *
2+
* Copyright (c) 2015 Stefan Tröger <[email protected]> *
33
* Copyright (c) 2015 Alexander Golubev (Fat-Zer) <[email protected]> *
44
* Copyright (c) 2024 Ondsel (PL Boyer) <[email protected]> *
55
* *
6-
* This file is part of the FreeCAD CAx development system. *
6+
* This file is part of FreeCAD. *
77
* *
8-
* This library is free software; you can redistribute it and/or *
9-
* modify it under the terms of the GNU Library General Public *
10-
* License as published by the Free Software Foundation; either *
11-
* version 2 of the License, or (at your option) any later version. *
8+
* FreeCAD is free software: you can redistribute it and/or modify it *
9+
* under the terms of the GNU Lesser General Public License as *
10+
* published by the Free Software Foundation, either version 2.1 of the *
11+
* License, or (at your option) any later version. *
1212
* *
13-
* This library is distributed in the hope that it will be useful, *
14-
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
15-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16-
* GNU Library General Public License for more details. *
13+
* FreeCAD is distributed in the hope that it will be useful, but *
14+
* WITHOUT ANY WARRANTY; without even the implied warranty of *
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16+
* Lesser General Public License for more details. *
1717
* *
18-
* You should have received a copy of the GNU Library General Public *
19-
* License along with this library; see the file COPYING.LIB. If not, *
20-
* write to the Free Software Foundation, Inc., 59 Temple Place, *
21-
* Suite 330, Boston, MA 02111-1307, USA *
18+
* You should have received a copy of the GNU Lesser General Public *
19+
* License along with FreeCAD. If not, see *
20+
* <https://www.gnu.org/licenses/>. *
2221
* *
2322
***************************************************************************/
2423

@@ -207,9 +206,9 @@ const std::vector<LocalCoordinateSystem::SetupData>& LocalCoordinateSystem::getS
207206
{
208207
static const std::vector<SetupData> setupData = {
209208
// clang-format off
210-
{App::Line::getClassTypeId(), AxisRoles[0], tr("X-axis"), Base::Rotation()},
211-
{App::Line::getClassTypeId(), AxisRoles[1], tr("Y-axis"), Base::Rotation(Base::Vector3d(1, 1, 1), M_PI * 2 / 3)},
212-
{App::Line::getClassTypeId(), AxisRoles[2], tr("Z-axis"), Base::Rotation(Base::Vector3d(1,-1, 1), M_PI * 2 / 3)},
209+
{App::Line::getClassTypeId(), AxisRoles[0], tr("X-axis"), Base::Rotation(Base::Vector3d(1, 1, 1), M_PI * 2 / 3)},
210+
{App::Line::getClassTypeId(), AxisRoles[1], tr("Y-axis"), Base::Rotation(Base::Vector3d(-1, 1, 1), M_PI * 2 / 3)},
211+
{App::Line::getClassTypeId(), AxisRoles[2], tr("Z-axis"), Base::Rotation()},
213212
{App::Plane::getClassTypeId(), PlaneRoles[0], tr("XY-plane"), Base::Rotation()},
214213
{App::Plane::getClassTypeId(), PlaneRoles[1], tr("XZ-plane"), Base::Rotation(1.0, 0.0, 0.0, 1.0)},
215214
{App::Plane::getClassTypeId(), PlaneRoles[2], tr("YZ-plane"), Base::Rotation(Base::Vector3d(1, 1, 1), M_PI * 2 / 3)},
@@ -277,6 +276,56 @@ void LocalCoordinateSystem::unsetupObject()
277276
}
278277
}
279278

279+
void LocalCoordinateSystem::onDocumentRestored()
280+
{
281+
GeoFeature::onDocumentRestored();
282+
283+
// In 0.22 origins did not have point.
284+
migrateOriginPoint();
285+
286+
// In 0.22 the axis placement were wrong. The X axis had identity placement instead of the Z.
287+
// This was fixed but we need to migrate old files.
288+
migrateXAxisPlacement();
289+
}
290+
291+
void LocalCoordinateSystem::migrateOriginPoint()
292+
{
293+
auto features = OriginFeatures.getValues();
294+
295+
auto isOrigin = [](App::DocumentObject* obj) {
296+
return obj->isDerivedFrom<App::DatumElement>() &&
297+
strcmp(static_cast<App::DatumElement*>(obj)->Role.getValue(), PointRoles[0]) == 0;
298+
};
299+
if (std::none_of(features.begin(), features.end(), isOrigin)) {
300+
auto data = getData(PointRoles[0]);
301+
auto* origin = createDatum(data);
302+
features.push_back(origin);
303+
OriginFeatures.setValues(features);
304+
}
305+
}
306+
307+
void LocalCoordinateSystem::migrateXAxisPlacement()
308+
{
309+
constexpr const double tolerance = 1e-5;
310+
auto features = OriginFeatures.getValues();
311+
312+
const auto& setupData = getSetupData();
313+
for (auto* obj : features) {
314+
auto* feature = dynamic_cast <App::DatumElement*> (obj);
315+
if (!feature) { continue; }
316+
for (auto data : setupData) {
317+
// ensure the rotation is correct for the role
318+
if (std::strcmp(feature->Role.getValue(), data.role) == 0) {
319+
if (!feature->Placement.getValue().getRotation().isSame(data.rot, tolerance)) {
320+
feature->Placement.setValue(Base::Placement(Base::Vector3d(), data.rot));
321+
getDocument()->setStatus(App::Document::MigrateLCS, true);
322+
}
323+
break;
324+
}
325+
}
326+
}
327+
}
328+
280329
// ----------------------------------------------------------------------------
281330

282331
LocalCoordinateSystem::LCSExtension::LCSExtension(LocalCoordinateSystem* obj)

src/App/Datums.h

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,21 @@
33
* Copyright (c) 2015 Alexander Golubev (Fat-Zer) <[email protected]> *
44
* Copyright (c) 2024 Ondsel (PL Boyer) <[email protected]> *
55
* *
6-
* This file is part of the FreeCAD CAx development system. *
6+
* This file is part of FreeCAD. *
77
* *
8-
* This library is free software; you can redistribute it and/or *
9-
* modify it under the terms of the GNU Library General Public *
10-
* License as published by the Free Software Foundation; either *
11-
* version 2 of the License, or (at your option) any later version. *
8+
* FreeCAD is free software: you can redistribute it and/or modify it *
9+
* under the terms of the GNU Lesser General Public License as *
10+
* published by the Free Software Foundation, either version 2.1 of the *
11+
* License, or (at your option) any later version. *
1212
* *
13-
* This library is distributed in the hope that it will be useful, *
14-
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
15-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16-
* GNU Library General Public License for more details. *
13+
* FreeCAD is distributed in the hope that it will be useful, but *
14+
* WITHOUT ANY WARRANTY; without even the implied warranty of *
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16+
* Lesser General Public License for more details. *
1717
* *
18-
* You should have received a copy of the GNU Library General Public *
19-
* License along with this library; see the file COPYING.LIB. If not, *
20-
* write to the Free Software Foundation, Inc., 59 Temple Place, *
21-
* Suite 330, Boston, MA 02111-1307, USA *
18+
* You should have received a copy of the GNU Lesser General Public *
19+
* License along with FreeCAD. If not, see *
20+
* <https://www.gnu.org/licenses/>. *
2221
* *
2322
***************************************************************************/
2423

@@ -201,7 +200,7 @@ class AppExport LocalCoordinateSystem: public App::GeoFeature
201200
virtual bool isOrigin()
202201
{
203202
return false;
204-
};
203+
}
205204

206205
// Axis links
207206
PropertyLinkList OriginFeatures;
@@ -213,6 +212,7 @@ class AppExport LocalCoordinateSystem: public App::GeoFeature
213212
void setupObject() override;
214213
/// Removes all planes and axis if they are still linked to the document
215214
void unsetupObject() override;
215+
void onDocumentRestored() override;
216216

217217
private:
218218
struct SetupData;
@@ -245,6 +245,9 @@ class AppExport LocalCoordinateSystem: public App::GeoFeature
245245

246246
DatumElement* createDatum(SetupData& data);
247247
SetupData getData(const char* role);
248+
249+
void migrateOriginPoint();
250+
void migrateXAxisPlacement();
248251
};
249252

250253
} // namespace App

src/App/Document.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class AppExport Document: public App::PropertyContainer
7777
LinkStampChanged = 11, // Indicates during restore time if any linked document's time stamp has changed
7878
IgnoreErrorOnRecompute = 12, // Don't report errors if the recompute failed
7979
RecomputeOnRestore = 13, // Mark pending recompute on restore for migration purposes
80+
MigrateLCS = 14 // Migrate local coordinate system of older versions
8081
};
8182
// clang-format on
8283

0 commit comments

Comments
 (0)