Merge branch 'main' into erase-version-4

This commit is contained in:
mac-the-bike
2023-12-14 13:33:42 +00:00
committed by GitHub
1547 changed files with 117515 additions and 97184 deletions
+1 -1
View File
@@ -152,7 +152,7 @@ CheckOptions:
- key: google-readability-braces-around-statements.ShortStatementLines
value: '1'
- key: bugprone-reserved-identifier.AllowedIdentifiers
value: ''
value: '_object'
- key: cppcoreguidelines-pro-type-member-init.IgnoreArrays
value: 'false'
- key: readability-else-after-return.WarnOnUnfixable
+32 -4
View File
@@ -39,17 +39,30 @@ jobs:
with:
artifactBasename: Prepare-${{ github.run_id }}
# GA in Jan-Mar 2024 Timeframe: https://github.com/actions/runner-images/issues/8439#issuecomment-1755601587
# MacOS_13_Conda_Apple:
# needs: [Prepare]
# uses: ./.github/workflows/sub_buildMacOSCondaApple.yml
# with:
# artifactBasename: MacOS_13_Conda_Apple-${{ github.run_id }}
MacOS_13_Conda_Intel:
needs: [Prepare]
uses: ./.github/workflows/sub_buildMacOSCondaIntel.yml
with:
artifactBasename: MacOS_13_Conda_Intel-${{ github.run_id }}
Ubuntu_20-04:
needs: [Prepare]
uses: ./.github/workflows/sub_buildUbuntu2004.yml
with:
artifactBasename: Ubuntu_20-04-${{ github.run_id }}
Ubuntu_22-04:
Ubuntu_22-04_Conda:
needs: [Prepare]
uses: ./.github/workflows/sub_buildUbuntu2204.yml
uses: ./.github/workflows/sub_buildUbuntu2204Conda.yml
with:
artifactBasename: Ubuntu_22-04-${{ github.run_id }}
artifactBasename: Ubuntu_22-04_Conda-${{ github.run_id }}
Windows:
needs: [Prepare]
@@ -57,6 +70,12 @@ jobs:
with:
artifactBasename: Windows-${{ github.run_id }}
Windows_Conda:
needs: [Prepare]
uses: ./.github/workflows/sub_buildWindowsConda.yml
with:
artifactBasename: Windows_Conda-${{ github.run_id }}
Lint:
needs: [Prepare]
uses: ./.github/workflows/sub_lint.yml
@@ -67,7 +86,16 @@ jobs:
changedPythonFiles: ${{ needs.Prepare.outputs.changedPythonFiles }}
WrapUp:
needs: [Prepare, Ubuntu_20-04, Ubuntu_22-04, Windows, Lint]
needs: [
Prepare,
# MacOS_13_Conda_Apple,
MacOS_13_Conda_Intel,
Ubuntu_20-04,
Ubuntu_22-04_Conda,
Windows,
Windows_Conda,
Lint
]
if: always()
uses: ./.github/workflows/sub_wrapup.yml
with:
@@ -46,12 +46,12 @@ runs:
steps:
- name: Build
id: build
shell: bash
shell: bash -l {0}
run: |
(stdbuf -oL -eL cmake --build ${{ inputs.builddir }} -j$(nproc) ${{ inputs.extraParameters }}) \
2> >(tee -a ${{ inputs.errorFile }}) | tee -a ${{ inputs.logFile }}
- name: Write report
shell: bash
shell: bash -l {0}
if: always()
run: |
if [ ${{ steps.build.outcome }} == 'success' ]
@@ -50,12 +50,12 @@ runs:
steps:
- name: Configure CMake
id: configure
shell: bash
shell: bash -l {0}
run: |
(stdbuf -oL -eL cmake -S ${{ inputs.sourcedir }} -B ${{ inputs.builddir }} -D CMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE ${{inputs.extraParameters }}) \
2> >(tee -a ${{ inputs.errorFile }}) | tee -a ${{ inputs.logFile }}
- name: Write report
shell: bash
shell: bash -l {0}
if: always()
run: |
if [ ${{ steps.configure.outcome }} == 'success' ]
@@ -37,8 +37,8 @@ runs:
using: "composite"
steps:
- id: generateCacheKey
shell: bash
shell: bash -l {0}
run: |
cacheKey=$(lsb_release -ds | tr -d ' ')-$( basename ${{ inputs.compiler }})$(${{ inputs.compiler }} -dumpfullversion -dumpversion)
cacheKey=$(lsb_release -ds | tr -d ' ')-$(basename ${{ inputs.compiler }})$(${{ inputs.compiler }} -dumpfullversion -dumpversion)
echo "Generated cache key : $cacheKey"
echo "cacheKey=$cacheKey" >> $GITHUB_OUTPUT
@@ -46,12 +46,12 @@ runs:
steps:
- name: Install
id: install
shell: bash
shell: bash -l {0}
run: |
(stdbuf -oL -eL sudo cmake --install ${{ inputs.builddir }} ${{ inputs.extraParameters }}) \
2> >(tee -a ${{ inputs.errorFile }}) | tee -a ${{ inputs.logFile }}
- name: Write report
shell: bash
shell: bash -l {0}
if: always()
run: |
if [ ${{ steps.install.outcome }} == 'success' ]
@@ -0,0 +1,73 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
# ***************************************************************************
# * *
# * Copyright (c) 2023 0penBrain. *
# * *
# * This file is part of FreeCAD. *
# * *
# * FreeCAD is free software: you can redistribute it and/or modify it *
# * under the terms of the GNU Lesser General Public License as *
# * published by the Free Software Foundation, either version 2.1 of the *
# * License, or (at your option) any later version. *
# * *
# * FreeCAD is distributed in the hope that it will be useful, but *
# * WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
# * Lesser General Public License for more details. *
# * *
# * You should have received a copy of the GNU Lesser General Public *
# * License along with FreeCAD. If not, see *
# * <https://www.gnu.org/licenses/>. *
# * *
# ***************************************************************************
name: build
description: "macOS: build application"
inputs:
builddir:
description: "Directory where build will happen"
required: true
logFile:
description: "Path for log file"
required: true
errorFile:
description: "Path to error file"
required: true
reportFile:
description: "Path for report file"
required: true
extraParameters:
description: "Extra parameters to CMake build"
required: false
runs:
using: "composite"
steps:
- name: Build
id: build
shell: bash -l {0}
run: |
(cmake --build ${{ inputs.builddir }} -j$(nproc) ${{ inputs.extraParameters }}) \
2> >(tee -a ${{ inputs.errorFile }}) | tee -a ${{ inputs.logFile }}
- name: Write report
shell: bash -l {0}
if: always()
run: |
if [ ${{ steps.build.outcome }} == 'success' ]
then
echo "<details><summary>:heavy_check_mark: CMake build succeeded</summary>" >> ${{ inputs.reportFile }}
else
echo "<details><summary>:fire: CMake build failed</summary>" >> ${{ inputs.reportFile }}
fi
echo "" >> ${{ inputs.reportFile }}
echo "Build Error Log (stderr output):" >> ${{ inputs.reportFile }}
echo '```' >> ${{ inputs.reportFile }}
cat ${{ inputs.errorFile }} >> ${{ inputs.reportFile }}
echo '```' >> ${{ inputs.reportFile }}
echo "Build Log (only built targets reported):" >> ${{ inputs.reportFile }}
echo '```' >> ${{ inputs.reportFile }}
cat ${{ inputs.logFile }} | sed -ne "/Built target/p" >> ${{ inputs.reportFile }}
echo '```' >> ${{ inputs.reportFile }}
echo "</details>">> ${{ inputs.reportFile }}
echo "" >> ${{ inputs.reportFile }}
@@ -0,0 +1,78 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
# ***************************************************************************
# * *
# * Copyright (c) 2023 0penBrain. *
# * *
# * This file is part of FreeCAD. *
# * *
# * FreeCAD is free software: you can redistribute it and/or modify it *
# * under the terms of the GNU Lesser General Public License as *
# * published by the Free Software Foundation, either version 2.1 of the *
# * License, or (at your option) any later version. *
# * *
# * FreeCAD is distributed in the hope that it will be useful, but *
# * WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
# * Lesser General Public License for more details. *
# * *
# * You should have received a copy of the GNU Lesser General Public *
# * License along with FreeCAD. If not, see *
# * <https://www.gnu.org/licenses/>. *
# * *
# ***************************************************************************
name: configure
description: "macOS: configure CMake"
inputs:
sourcedir:
description: "Directory where sources are stored"
required: false
default: ./
builddir:
description: "Directory where build will happen"
required: true
logFile:
description: "Path for log file"
required: true
errorFile:
description: "Path to error file"
required: true
reportFile:
description: "Path for report file"
required: true
extraParameters:
description: "Extra parameters to CMake configure"
required: false
runs:
using: "composite"
steps:
- name: Configure CMake
id: configure
shell: bash -l {0}
run: |
(cmake -S ${{ inputs.sourcedir }} -B ${{ inputs.builddir }} -D CMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE ${{inputs.extraParameters }}) \
2> >(tee -a ${{ inputs.errorFile }}) | tee -a ${{ inputs.logFile }}
- name: Write report
shell: bash -l {0}
if: always()
run: |
if [ ${{ steps.configure.outcome }} == 'success' ]
then
echo "<details><summary>:heavy_check_mark: CMake configure succeeded</summary>" >> ${{ inputs.reportFile }}
echo "" >> ${{ inputs.reportFile }}
echo "Configure Error Log (stderr output):" >> ${{ inputs.reportFile }}
echo '```' >> ${{ inputs.reportFile }}
cat ${{ inputs.errorFile }} >> ${{ inputs.reportFile }}
echo '```' >> ${{ inputs.reportFile }}
else
echo "<details><summary>:fire: CMake configure failed</summary>" >> ${{ inputs.reportFile }}
fi
echo "" >> ${{ inputs.reportFile }}
echo "Configure Log (only final configuration values reported):" >> ${{ inputs.reportFile }}
echo '```' >> ${{ inputs.reportFile }}
cat ${{ inputs.logFile }} | sed -ne "/^ *==/,/^====/p" >> ${{ inputs.reportFile }}
echo '```' >> ${{ inputs.reportFile }}
echo "</details>">> ${{ inputs.reportFile }}
echo "" >> ${{ inputs.reportFile }}
@@ -0,0 +1,44 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
# ***************************************************************************
# * *
# * Copyright (c) 2023 0penBrain. *
# * *
# * This file is part of FreeCAD. *
# * *
# * FreeCAD is free software: you can redistribute it and/or modify it *
# * under the terms of the GNU Lesser General Public License as *
# * published by the Free Software Foundation, either version 2.1 of the *
# * License, or (at your option) any later version. *
# * *
# * FreeCAD is distributed in the hope that it will be useful, but *
# * WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
# * Lesser General Public License for more details. *
# * *
# * You should have received a copy of the GNU Lesser General Public *
# * License along with FreeCAD. If not, see *
# * <https://www.gnu.org/licenses/>. *
# * *
# ***************************************************************************
name: generateCacheKey
description: "macOS: generates a cache key taking into account distro and compiler"
inputs:
compiler:
description: "Binary name/path of compiler to be used"
required: true
outputs:
cacheKey:
description: "Cache key with distro and compiler version"
value: ${{ steps.generateCacheKey.outputs.cacheKey }}
runs:
using: "composite"
steps:
- id: generateCacheKey
shell: bash -l {0}
run: |
cacheKey=$(sw_vers --productName)-$(sw_vers --productVersion)-$(basename ${{ inputs.compiler }})$(${{ inputs.compiler }} -dumpfullversion -dumpversion)
echo "Generated cache key : $cacheKey"
echo "cacheKey=$cacheKey" >> $GITHUB_OUTPUT
@@ -0,0 +1,73 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
# ***************************************************************************
# * *
# * Copyright (c) 2023 0penBrain. *
# * *
# * This file is part of FreeCAD. *
# * *
# * FreeCAD is free software: you can redistribute it and/or modify it *
# * under the terms of the GNU Lesser General Public License as *
# * published by the Free Software Foundation, either version 2.1 of the *
# * License, or (at your option) any later version. *
# * *
# * FreeCAD is distributed in the hope that it will be useful, but *
# * WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
# * Lesser General Public License for more details. *
# * *
# * You should have received a copy of the GNU Lesser General Public *
# * License along with FreeCAD. If not, see *
# * <https://www.gnu.org/licenses/>. *
# * *
# ***************************************************************************
name: install
description: "macOS: install application"
inputs:
builddir:
description: "Directory where build is stored"
required: true
logFile:
description: "Path for log file"
required: true
errorFile:
description: "Path to error file"
required: true
reportFile:
description: "Path for report file"
required: true
extraParameters:
description: "Extra parameters to CMake install"
required: false
runs:
using: "composite"
steps:
- name: Install
id: install
shell: bash -l {0}
run: |
(sudo cmake --install ${{ inputs.builddir }} ${{ inputs.extraParameters }}) \
2> >(tee -a ${{ inputs.errorFile }}) | tee -a ${{ inputs.logFile }}
- name: Write report
shell: bash -l {0}
if: always()
run: |
if [ ${{ steps.install.outcome }} == 'success' ]
then
echo "<details><summary>:heavy_check_mark: CMake install succeeded</summary>" >> ${{ inputs.reportFile }}
else
echo "<details><summary>:fire: CMake install failed</summary>" >> ${{ inputs.reportFile }}
fi
echo "" >> ${{ inputs.reportFile }}
echo "Install Error Log (stderr output):" >> ${{ inputs.reportFile }}
echo '```' >> ${{ inputs.reportFile }}
cat ${{ inputs.errorFile }} >> ${{ inputs.reportFile }}
echo '```' >> ${{ inputs.reportFile }}
echo "Install Error Log (stdout output trimmed to the last 100 Lines):" >> ${{ inputs.reportFile }}
echo '```' >> ${{ inputs.reportFile }}
tail -n 100 ${{ inputs.logFile }} >> ${{ inputs.reportFile }}
echo '```' >> ${{ inputs.reportFile }}
echo "</details>">> ${{ inputs.reportFile }}
echo "" >> ${{ inputs.reportFile }}
@@ -84,7 +84,7 @@ runs:
testName: Sketcher
- name: Compose summary report based on test results
if: always()
shell: bash
shell: bash -l {0}
run: |
# Print global result
if [ ${{ job.status }} != "success" ]
@@ -104,4 +104,3 @@ runs:
echo "</blockquote>" >> ${{ inputs.reportFile }}
echo "</details>" >> ${{ inputs.reportFile }}
echo "" >> ${{ inputs.reportFile }}
@@ -44,12 +44,12 @@ runs:
using: "composite"
steps:
- name: Run C++ tests
shell: bash
run: stdbuf -oL -eL ${{ inputs.testCommand }} |& tee -a ${{ inputs.testLogFile }}
shell: bash -l {0}
run: ${{ inputs.testCommand }} | tee -a ${{ inputs.testLogFile }}
- name: Parse test results
if: always()
id: report
shell: bash
shell: bash -l {0}
run: |
result=$(sed -ne "/Global test environment tear-down/,/^$/{/^$/d;p}" ${{ inputs.testLogFile }})
if grep -qF "[ FAILED ]" <<< $result
@@ -43,11 +43,11 @@ runs:
steps:
- name: Run tests
id: runTests
shell: bash
shell: bash -l {0}
run: |
stdbuf -oL -eL ${{ inputs.testCommand }} |& sed -Ee "/[[:blank:]]*\([[:digit:]]{1,3} %\)[[:blank:]]*/d" | tee -a ${{ inputs.logFile }}
${{ inputs.testCommand }} | sed -Ee "/[[:blank:]]*\([[:digit:]]{1,3} %\)[[:blank:]]*/d" | tee -a ${{ inputs.logFile }}
- name: Write report
shell: bash
shell: bash -l {0}
if: always()
run: |
sed -ne "/^\(FAILED\|ERROR\):/,/^[[:blank:]]*$/bF; /^Traceback/,/^[^[:blank:]]/{/^Traceback/bT; /^[^[:blank:]]/G; bT}; b; :T w ${{ inputs.logFile }}_tracebacks" -e "b; :F w ${{ inputs.logFile }}_failedtests" ${{ inputs.logFile }}
@@ -0,0 +1,166 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
# ***************************************************************************
# * *
# * Copyright (c) 2023 0penBrain. *
# * *
# * This file is part of FreeCAD. *
# * *
# * FreeCAD is free software: you can redistribute it and/or modify it *
# * under the terms of the GNU Lesser General Public License as *
# * published by the Free Software Foundation, either version 2.1 of the *
# * License, or (at your option) any later version. *
# * *
# * FreeCAD is distributed in the hope that it will be useful, but *
# * WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
# * Lesser General Public License for more details. *
# * *
# * You should have received a copy of the GNU Lesser General Public *
# * License along with FreeCAD. If not, see *
# * <https://www.gnu.org/licenses/>. *
# * *
# ***************************************************************************
# This is a build and test workflow for CI of FreeCAD.
# This workflow aims at building and testing FreeCAD on a Conda environment on macOS.
name: Build macOS 13 (Apple Silicon)
on:
workflow_call:
inputs:
artifactBasename:
type: string
required: true
testOnBuildDir:
default: false
type: boolean
required: false
allowedToFail:
default: false
type: boolean
required: false
outputs:
reportFile:
value: ${{ jobs.Build.outputs.reportFile }}
jobs:
Build:
runs-on: macos-13-xlarge
continue-on-error: ${{ inputs.allowedToFail }}
env:
CCACHE_DIR: ${{ github.workspace }}/ccache
CCACHE_CONFIGPATH: ${{ github.workspace }}/ccache/config
CCACHE_MAXSIZE: 1G
CCACHE_COMPILERCHECK: "%compiler% -dumpfullversion -dumpversion" # default:mtime
CCACHE_COMPRESS: true
CCACHE_COMPRESSLEVEL: 1
CC: arm64-apple-darwin20.0.0-clang
CXX: arm64-apple-darwin20.0.0-clang++
builddir: ${{ github.workspace }}/build/release/
logdir: /tmp/logs/
reportdir: /tmp/report/
reportfilename: ${{ inputs.artifactBasename }}-report.md
defaults:
run:
shell: bash -l {0}
outputs:
reportFile: ${{ steps.Init.outputs.reportFile }}
steps:
- name: Checking out source code
uses: actions/checkout@v3
with:
submodules: true
- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: .conda/freecad
environment-file: conda/conda-env.yaml
channels: conda-forge,defaults
channel-priority: true
miniforge-version: latest
- name: Install FreeCAD dependencies
run: |
./conda/setup-environment.sh
- name: Set Environment Variables
run: |
echo "CC=$CC" >> "$GITHUB_ENV"
echo "CXX=$CXX" >> "$GITHUB_ENV"
- name: Make needed directories, files and initializations
id: Init
run: |
mkdir -p ${{ env.CCACHE_DIR }}
mkdir -p ${{ env.CCACHE_CONFIGPATH }}
mkdir -p ${{ env.builddir }}
mkdir -p ${{ env.logdir }}
mkdir -p ${{ env.reportdir }}
echo "reportFile=${{ env.reportfilename }}" >> $GITHUB_OUTPUT
- name: Generate cache key
id: genCacheKey
uses: ./.github/workflows/actions/macos/generateCacheKey
with:
compiler: ${{ env.CXX }}
- name: Restore Compiler Cache
uses: pat-s/always-upload-cache@v3
with:
path: ${{ env.CCACHE_DIR }}
key: FC-${{ steps.genCacheKey.outputs.cacheKey }}-${{ github.ref }}-${{ github.run_id }}
restore-keys: |
FC-${{ steps.genCacheKey.outputs.cacheKey }}-${{ github.ref }}-
FC-${{ steps.genCacheKey.outputs.cacheKey }}-
- name: Print CCache statistics before build, reset stats and print config
run: |
ccache -s
ccache -z
ccache -p
- name: CMake Configure
run: |
mamba run --live-stream -p .conda/freecad cmake --preset conda-macos-release -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/.conda/freecad/opt/freecad
- name: CMake Build
run: |
mamba run --live-stream -p .conda/freecad cmake --build build/release
- name: Print ccache statistics after Build
run: |
ccache -s
- name: FreeCAD CLI tests on build dir
if: inputs.testOnBuildDir
timeout-minutes: 10
uses: ./.github/workflows/actions/runPythonTests
with:
testDescription: "CLI tests on build dir"
testCommand: ${{ env.builddir }}/bin/FreeCADCmd -t 0
logFile: ${{ env.logdir }}TestCLIBuild.log
reportFile: ${{env.reportdir}}${{ env.reportfilename }}
- name: C++ tests
timeout-minutes: 1
uses: ./.github/workflows/actions/runCPPTests/runAllTests
with:
reportdir: ${{ env.reportdir }}
builddir: ${{ env.builddir }}
reportFile: ${{ env.reportdir }}${{ env.reportfilename }}
- name: CMake Install
run: |
mamba run --live-stream -p .conda/freecad cmake --install build/release
- name: FreeCAD CLI tests on install
timeout-minutes: 10
uses: ./.github/workflows/actions/runPythonTests
with:
testDescription: "CLI tests on install"
testCommand: ${{ github.workspace }}/.conda/freecad/opt/freecad/bin/FreeCADCmd -t 0
logFile: ${{ env.logdir }}TestCLIInstall.log
reportFile: ${{env.reportdir}}${{ env.reportfilename }}
- name: Upload logs
if: always()
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.artifactBasename }}-Logs
path: |
${{ env.logdir }}
/var/crash/*FreeCAD*
- name: Upload report
if: always()
uses: actions/upload-artifact@v3
with:
name: ${{ env.reportfilename }}
path: |
${{env.reportdir}}${{ env.reportfilename }}
@@ -0,0 +1,166 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
# ***************************************************************************
# * *
# * Copyright (c) 2023 0penBrain. *
# * *
# * This file is part of FreeCAD. *
# * *
# * FreeCAD is free software: you can redistribute it and/or modify it *
# * under the terms of the GNU Lesser General Public License as *
# * published by the Free Software Foundation, either version 2.1 of the *
# * License, or (at your option) any later version. *
# * *
# * FreeCAD is distributed in the hope that it will be useful, but *
# * WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
# * Lesser General Public License for more details. *
# * *
# * You should have received a copy of the GNU Lesser General Public *
# * License along with FreeCAD. If not, see *
# * <https://www.gnu.org/licenses/>. *
# * *
# ***************************************************************************
# This is a build and test workflow for CI of FreeCAD.
# This workflow aims at building and testing FreeCAD on a Conda environment on macOS.
name: Build macOS 13 (Intel)
on:
workflow_call:
inputs:
artifactBasename:
type: string
required: true
testOnBuildDir:
default: false
type: boolean
required: false
allowedToFail:
default: false
type: boolean
required: false
outputs:
reportFile:
value: ${{ jobs.Build.outputs.reportFile }}
jobs:
Build:
runs-on: macos-13
continue-on-error: ${{ inputs.allowedToFail }}
env:
CCACHE_DIR: ${{ github.workspace }}/ccache
CCACHE_CONFIGPATH: ${{ github.workspace }}/ccache/config
CCACHE_MAXSIZE: 1G
CCACHE_COMPILERCHECK: "%compiler% -dumpfullversion -dumpversion" # default:mtime
CCACHE_COMPRESS: true
CCACHE_COMPRESSLEVEL: 1
CC: x86_64-apple-darwin13.4.0-clang
CXX: x86_64-apple-darwin13.4.0-clang++
builddir: ${{ github.workspace }}/build/release/
logdir: /tmp/logs/
reportdir: /tmp/report/
reportfilename: ${{ inputs.artifactBasename }}-report.md
defaults:
run:
shell: bash -l {0}
outputs:
reportFile: ${{ steps.Init.outputs.reportFile }}
steps:
- name: Checking out source code
uses: actions/checkout@v3
with:
submodules: true
- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: .conda/freecad
environment-file: conda/conda-env.yaml
channels: conda-forge,defaults
channel-priority: true
miniforge-version: latest
- name: Install FreeCAD dependencies
run: |
./conda/setup-environment.sh
- name: Set Environment Variables
run: |
echo "CC=$CC" >> "$GITHUB_ENV"
echo "CXX=$CXX" >> "$GITHUB_ENV"
- name: Make needed directories, files and initializations
id: Init
run: |
mkdir -p ${{ env.CCACHE_DIR }}
mkdir -p ${{ env.CCACHE_CONFIGPATH }}
mkdir -p ${{ env.builddir }}
mkdir -p ${{ env.logdir }}
mkdir -p ${{ env.reportdir }}
echo "reportFile=${{ env.reportfilename }}" >> $GITHUB_OUTPUT
- name: Generate cache key
id: genCacheKey
uses: ./.github/workflows/actions/macos/generateCacheKey
with:
compiler: ${{ env.CXX }}
- name: Restore Compiler Cache
uses: pat-s/always-upload-cache@v3
with:
path: ${{ env.CCACHE_DIR }}
key: FC-${{ steps.genCacheKey.outputs.cacheKey }}-${{ github.ref }}-${{ github.run_id }}
restore-keys: |
FC-${{ steps.genCacheKey.outputs.cacheKey }}-${{ github.ref }}-
FC-${{ steps.genCacheKey.outputs.cacheKey }}-
- name: Print CCache statistics before build, reset stats and print config
run: |
ccache -s
ccache -z
ccache -p
- name: CMake Configure
run: |
mamba run --live-stream -p .conda/freecad cmake --preset conda-macos-release -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/.conda/freecad/opt/freecad
- name: CMake Build
run: |
mamba run --live-stream -p .conda/freecad cmake --build build/release
- name: Print ccache statistics after Build
run: |
ccache -s
- name: FreeCAD CLI tests on build dir
if: inputs.testOnBuildDir
timeout-minutes: 10
uses: ./.github/workflows/actions/runPythonTests
with:
testDescription: "CLI tests on build dir"
testCommand: ${{ env.builddir }}/bin/FreeCADCmd -t 0
logFile: ${{ env.logdir }}TestCLIBuild.log
reportFile: ${{env.reportdir}}${{ env.reportfilename }}
- name: C++ tests
timeout-minutes: 1
uses: ./.github/workflows/actions/runCPPTests/runAllTests
with:
reportdir: ${{ env.reportdir }}
builddir: ${{ env.builddir }}
reportFile: ${{ env.reportdir }}${{ env.reportfilename }}
- name: CMake Install
run: |
mamba run --live-stream -p .conda/freecad cmake --install build/release
- name: FreeCAD CLI tests on install
timeout-minutes: 10
uses: ./.github/workflows/actions/runPythonTests
with:
testDescription: "CLI tests on install"
testCommand: ${{ github.workspace }}/.conda/freecad/opt/freecad/bin/FreeCADCmd -t 0
logFile: ${{ env.logdir }}TestCLIInstall.log
reportFile: ${{env.reportdir}}${{ env.reportfilename }}
- name: Upload logs
if: always()
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.artifactBasename }}-Logs
path: |
${{ env.logdir }}
/var/crash/*FreeCAD*
- name: Upload report
if: always()
uses: actions/upload-artifact@v3
with:
name: ${{ env.reportfilename }}
path: |
${{env.reportdir}}${{ env.reportfilename }}
+6 -4
View File
@@ -60,7 +60,7 @@ jobs:
CXX: /usr/bin/g++
#CC: /usr/bin/clang
#CXX: /usr/bin/clang++
builddir: ${{ github.workspace }}/build/
builddir: ${{ github.workspace }}/build/release/
logdir: /tmp/logs/
reportdir: /tmp/report/
reportfilename: ${{ inputs.artifactBasename }}-report.md
@@ -79,6 +79,7 @@ jobs:
run: |
sudo apt-get update -qq
sudo apt-get install -y --no-install-recommends \
ccache \
doxygen \
graphviz \
imagemagick \
@@ -117,6 +118,7 @@ jobs:
libzipios++-dev \
netgen \
netgen-headers \
ninja-build \
occt-draw \
pyqt5-dev-tools \
pyside2-tools \
@@ -131,17 +133,16 @@ jobs:
python3-pyside2.qtgui \
python3-pyside2.qtnetwork \
python3-pyside2.qtsvg \
python3-pyside2.qtwebchannel \
python3-pyside2.qtwebengine \
python3-pyside2.qtwebenginecore \
python3-pyside2.qtwebenginewidgets \
python3-pyside2.qtwebchannel \
python3-pyside2.qtwidgets \
qtbase5-dev \
qttools5-dev \
qtwebengine5-dev \
shiboken2 \
swig \
ccache \
xvfb
- name: Make needed directories, files and initializations
id: Init
@@ -173,6 +174,7 @@ jobs:
- name: CMake Configure
uses: ./.github/workflows/actions/linux/configure
with:
extraParameters: -G Ninja --preset release
builddir: ${{ env.builddir }}
logFile: ${{ env.logdir }}Cmake.log
errorFile: ${{ env.logdir }}CmakeErrors.log
@@ -193,7 +195,7 @@ jobs:
uses: ./.github/workflows/actions/runPythonTests
with:
testDescription: "CLI tests on build dir"
testCommand: ${{ env.builddir }}bin/FreeCADCmd -t 0
testCommand: ${{ env.builddir }}/bin/FreeCADCmd -t 0
logFile: ${{ env.logdir }}TestCLIBuild.log
reportFile: ${{env.reportdir}}${{ env.reportfilename }}
- name: FreeCAD GUI tests on build dir
@@ -22,9 +22,9 @@
# ***************************************************************************
# This is a build and test workflow for CI of FreeCAD.
# This workflow aims at building and testing FreeCAD on Ubuntu 22.04 using Clang.
# This workflow aims at building and testing FreeCAD on a Conda environment on Linux.
name: Build Ubuntu 22.04
name: Build Ubuntu 22.04 (Conda)
on:
workflow_call:
inputs:
@@ -54,17 +54,13 @@ jobs:
CCACHE_COMPILERCHECK: "%compiler% -dumpfullversion -dumpversion" # default:mtime
CCACHE_COMPRESS: true
CCACHE_COMPRESSLEVEL: 1
#CC: /usr/bin/gcc
#CXX: /usr/bin/g++
CC: /usr/bin/clang
CXX: /usr/bin/clang++
builddir: ${{ github.workspace }}/build/
builddir: ${{ github.workspace }}/build/release/
logdir: /tmp/logs/
reportdir: /tmp/report/
reportfilename: ${{ inputs.artifactBasename }}-report.md
defaults:
run:
shell: bash
shell: bash -l {0}
outputs:
reportFile: ${{ steps.Init.outputs.reportFile }}
@@ -73,74 +69,21 @@ jobs:
uses: actions/checkout@v3
with:
submodules: true
- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: .conda/freecad
environment-file: conda/conda-env.yaml
channels: conda-forge,defaults
channel-priority: true
miniforge-version: latest
- name: Install FreeCAD dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -y --no-install-recommends \
doxygen \
graphviz \
imagemagick \
libboost-date-time-dev \
libboost-dev \
libboost-filesystem-dev \
libboost-graph-dev \
libboost-iostreams-dev \
libboost-program-options-dev \
libboost-python-dev \
libboost-regex-dev \
libboost-serialization-dev \
libboost-thread-dev \
libcoin-dev \
libeigen3-dev \
libgts-bin \
libgts-dev \
libkdtree++-dev \
libmedc-dev \
libocct-data-exchange-dev \
libocct-ocaf-dev \
libocct-visualization-dev \
libopencv-dev \
libproj-dev \
libpyside2-dev \
libqt5opengl5-dev \
libqt5svg5-dev \
libqt5x11extras5-dev \
libqt5xmlpatterns5-dev \
libshiboken2-dev \
libspnav-dev \
libvtk7-dev \
libx11-dev \
libxerces-c-dev \
libyaml-cpp-dev \
libzipios++-dev \
netgen \
netgen-headers \
occt-draw \
pyqt5-dev-tools \
pyside2-tools \
python3-dev \
python3-git \
python3-markdown \
python3-matplotlib \
python3-packaging \
python3-pivy \
python3-ply \
python3-pyside2.qtcore \
python3-pyside2.qtgui \
python3-pyside2.qtnetwork \
python3-pyside2.qtsvg \
python3-pyside2.qtwebengine \
python3-pyside2.qtwebenginecore \
python3-pyside2.qtwebenginewidgets \
python3-pyside2.qtwebchannel \
python3-pyside2.qtwidgets \
qtbase5-dev \
qttools5-dev \
qtwebengine5-dev \
shiboken2 \
swig \
ccache \
xvfb
./conda/setup-environment.sh
- name: Set Environment Variables
run: |
echo "CC=$CC" >> "$GITHUB_ENV"
echo "CXX=$CXX" >> "$GITHUB_ENV"
- name: Make needed directories, files and initializations
id: Init
run: |
@@ -171,6 +114,7 @@ jobs:
- name: CMake Configure
uses: ./.github/workflows/actions/linux/configure
with:
extraParameters: --preset conda-linux-release -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/.conda/freecad/opt/freecad
builddir: ${{ env.builddir }}
logFile: ${{ env.logdir }}Cmake.log
errorFile: ${{ env.logdir }}CmakeErrors.log
@@ -191,7 +135,7 @@ jobs:
uses: ./.github/workflows/actions/runPythonTests
with:
testDescription: "CLI tests on build dir"
testCommand: ${{ env.builddir }}bin/FreeCADCmd -t 0
testCommand: ${{ env.builddir }}/bin/FreeCADCmd -t 0
logFile: ${{ env.logdir }}TestCLIBuild.log
reportFile: ${{env.reportdir}}${{ env.reportfilename }}
- name: FreeCAD GUI tests on build dir
@@ -222,7 +166,7 @@ jobs:
uses: ./.github/workflows/actions/runPythonTests
with:
testDescription: "CLI tests on install"
testCommand: FreeCADCmd -t 0
testCommand: ${{ github.workspace }}/.conda/freecad/opt/freecad/bin/FreeCADCmd -t 0
logFile: ${{ env.logdir }}TestCLIInstall.log
reportFile: ${{env.reportdir}}${{ env.reportfilename }}
- name: FreeCAD GUI tests on install
@@ -230,7 +174,7 @@ jobs:
uses: ./.github/workflows/actions/runPythonTests
with:
testDescription: "GUI tests on install"
testCommand: xvfb-run FreeCAD -t 0
testCommand: xvfb-run ${{ github.workspace }}/.conda/freecad/opt/freecad/bin/FreeCAD -t 0
logFile: ${{ env.logdir }}TestGUIInstall.log
reportFile: ${{env.reportdir}}${{ env.reportfilename }}
- name: Upload logs
+4 -3
View File
@@ -52,7 +52,7 @@ jobs:
#CCACHE_SLOPPINESS: "pch_defines,time_macros" # Can't get PCH to work on Windows
CCACHE_LOGFILE: C:/logs/ccache.log
## Have to use C:\ because not enough space on workspace drive
builddir: C:/FC/build/
builddir: C:/FC/build/release/
libpackdir: C:/FC/libpack/
ccachebindir: C:/FC/ccache/
logdir: C:/logs/
@@ -104,6 +104,7 @@ jobs:
- name: Configuring CMake
run: >
cmake -B"${{ env.builddir }}" .
--preset release
-DCMAKE_VS_NO_COMPILE_BATCHING=ON
-DCMAKE_BUILD_TYPE=Release
-DFREECAD_USE_PCH=OFF
@@ -132,10 +133,10 @@ jobs:
run: |
Move-Item -Force -Path ${{ env.libpackdir }}bin -Destination ${{ env.builddir }}
- name: C++ unit tests
if: false # Disabled because seems to not exist on Windows build
if: false # Disabled because seems to not function on Windows build
timeout-minutes: 1
run: |
. ${{ env.builddir }}\test\Tests_run --gtest_output=json:${{ env.reportdir }}gtest_results.json # 2>&1 | tee -filepath ${{ env.logdir }}\unitTests.log
. ${{ env.builddir }}\tests\Release\Tests_run --gtest_output=json:${{ env.reportdir }}gtest_results.json # 2>&1 | tee -filepath ${{ env.logdir }}\unitTests.log
- name: FreeCAD CLI tests
run: |
. ${{ env.builddir }}\bin\FreeCADCmd -t 0 # 2>&1 | tee -filepath ${{ env.logdir }}\integrationTests.log
+128
View File
@@ -0,0 +1,128 @@
# ***************************************************************************
# * Copyright (c) 2023 0penBrain *
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU Lesser General Public License (LGPL) *
# * as published by the Free Software Foundation; either version 2 of *
# * the License, or (at your option) any later version. *
# * for detail see the LICENCE text file. *
# * *
# * This program is distributed in the hope that it will be useful, *
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# * GNU Library General Public License for more details. *
# * *
# * You should have received a copy of the GNU Library General Public *
# * License along with this program; if not, write to the Free Software *
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************
# This is a build and test workflow for CI of FreeCAD.
# This workflow aims at building and testing FreeCAD using a Conda environment on Windows with MSVC.
name: Build Windows (Conda)
on:
workflow_call:
inputs:
artifactBasename:
type: string
required: true
allowedToFail:
default: false
type: boolean
required: false
outputs:
reportFile:
value: ${{ jobs.Build.outputs.reportFile }}
jobs:
Build:
runs-on: windows-latest
continue-on-error: ${{ inputs.allowedToFail }}
env:
CCACHE_DIR: C:/FC/cache/
CCACHE_COMPILERCHECK: "%compiler%" # default:mtime
CCACHE_MAXSIZE: 1G
CCACHE_COMPRESS: true
CCACHE_COMPRESSLEVEL: 1
CCACHE_NOHASHDIR: true
CCACHE_DIRECT: true
#CCACHE_SLOPPINESS: "pch_defines,time_macros" # Can't get PCH to work on Windows
CCACHE_LOGFILE: C:/logs/ccache.log
## Have to use C:\ because not enough space on workspace drive
builddir: C:/FC/build/
logdir: C:/logs/
reportdir: C:/report/
reportfilename: ${{ inputs.artifactBasename }}-report.md
outputs:
reportFile: ${{ steps.Init.outputs.reportFile }}
steps:
- name: Checking out source code
uses: actions/checkout@v3
with:
submodules: true
- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: .conda/freecad
environment-file: conda/conda-env.yaml
channels: conda-forge,defaults
channel-priority: true
miniforge-version: latest
- name: Install FreeCAD dependencies
run: |
conda config --add envs_dirs $PWD/.conda
mamba-devenv -f conda/environment.devenv.yml
- name: Make needed directories, files and initializations
id: Init
run: |
mkdir ${{ env.CCACHE_DIR }}
mkdir ${{ env.builddir }}
mkdir ${{ env.logdir }}
mkdir ${{ env.reportdir }}
echo "reportFile=${{ env.reportfilename }}" >> $GITHUB_OUTPUT
- name: Restore compiler cache
uses: pat-s/always-upload-cache@v3
with:
path: ${{ env.CCACHE_DIR }}
key: FC-Windows-Conda-${{ github.ref }}-${{ github.run_id }}
restore-keys: |
FC-Windows-Conda-${{ github.ref }}-
FC-Windows-Conda-
- name: Print Ccache statistics before build, reset stats and print config
run: |
ccache -s
ccache -z
ccache -p
- name: Configuring CMake
shell: cmd /C CALL {0}
run: >
conda\cmake.cmd --preset conda-windows-release -DFREECAD_USE_PCH:BOOL=OFF -DFREECAD_RELEASE_PDB:BOOL=OFF -DFREECAD_USE_CCACHE:BOOL=ON
- name: Compiling sources
shell: cmd /C CALL {0}
run: >
conda\cmake.cmd --build build\release
- name: Print Ccache statistics after build
run: |
ccache -s
- name: CMake Install
shell: cmd /C CALL {0}
run: |
conda\cmake.cmd --install build\release
- name: C++ unit tests
timeout-minutes: 1
run: |
. build\release\tests\Tests_run --gtest_output=json:${{ env.reportdir }}gtest_results.json # 2>&1 | tee -filepath ${{ env.logdir }}/unitTests.log
- name: FreeCAD CLI tests
run: |
. build\release\bin\FreeCADCmd -t 0 # 2>&1 | tee -filepath ${{ env.logdir }}/integrationTests.log
- name: Upload logs
if: always()
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.artifactBasename }}-Logs
path: |
${{ env.logdir }}
+2 -2
View File
@@ -83,8 +83,8 @@ jobs:
echo "### $icon $step step" >> report.md
if [ $result == 'skipped' ]
then
echo "Step was skipped, no report was generated" | tee -a report.md
continue
echo "Step was skipped, no report was generated" | tee -a report.md
continue
elif [ $result == 'cancelled' ]
then
echo "Step was cancelled when executing, report may be incomplete" | tee -a report.md
+2
View File
@@ -41,9 +41,11 @@ install_manifest.txt
/src/Tools/offlinedoc/localwiki/
/src/Tools/offlinedoc/*.txt
/conda/environment.yml
/.vscode/
OpenSCAD_rc.py
tags
/CMakeUserPresets.json
Testing
# crowdin file
src/Tools/freecad.zip
-12
View File
@@ -1,12 +0,0 @@
{
"configurations": [
{
"name": "FreeCAD",
"includePath": ["${workspaceFolder}/**"],
"cStandard": "c17",
"cppStandard": "c++17",
"configurationProvider": "ms-vscode.cmake-tools"
}
],
"version": 4
}
-18
View File
@@ -1,18 +0,0 @@
[
{
"name": "FreeCAD Linux",
"compilers": {
"C": "${workspaceFolder}/.conda/freecad/bin/cc",
"CXX": "${workspaceFolder}/.conda/freecad/bin/c++"
},
"environmentSetupScript": "${workspaceFolder}/.vscode/env.sh"
},
{
"name": "FreeCAD macOS",
"compilers": {
"C": "${workspaceFolder}/.conda/freecad/bin/clang",
"CXX": "${workspaceFolder}/.conda/freecad/bin/clang++"
},
"environmentSetupScript": "${workspaceFolder}/.vscode/env.sh"
}
]
-3
View File
@@ -1,3 +0,0 @@
#!/bin/bash
source activate freecad
-48
View File
@@ -1,48 +0,0 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "C/C++: Linux: build and debug FreeCAD",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/bin/FreeCAD",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"preLaunchTask": "CMake: build"
},
{
"name": "C/C++: macOS: build and debug FreeCAD",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/bin/FreeCAD",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb",
"preLaunchTask": "CMake: build"
},
{
"name": "Python: Remote Attach",
"type": "python",
"request": "attach",
"preLaunchTask": "conda: activate environment",
"redirectOutput": true,
"connect": {
"host": "localhost",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "${workspaceFolder}"
}
],
"justMyCode": false
}
]
}
-17
View File
@@ -1,17 +0,0 @@
{
"files.associations": {
"__config": "cpp",
"iosfwd": "cpp",
"vector": "cpp",
"tuple": "cpp"
},
"editor.formatOnType": true,
"cmake.preferredGenerators": ["Ninja", "NMake Makefiles"],
"cmake.cmakePath": "${workspaceFolder}/.conda/freecad/bin/cmake",
"cmake.configureSettings": {
"BUILD_WITH_CONDA:BOOL": "ON",
"BUILD_FEM_NETGEN:BOOL": "ON",
"FREECAD_USE_PYBIND11:BOOL": "ON",
"FREECAD_USE_EXTERNAL_SMESH:BOOL": "ON"
}
}
-58
View File
@@ -1,58 +0,0 @@
{
"tasks": [
{
"type": "shell",
"label": "conda: activate environment",
"command": "activate freecad",
"problemMatcher": [],
"detail": "Activate conda environment",
"group": "build"
},
{
"type": "cmake",
"label": "CMake: configure",
"command": "configure",
"problemMatcher": [],
"detail": "CMake template configure task",
"group": "build"
},
{
"type": "cmake",
"label": "CMake: build",
"command": "build",
"targets": ["all"],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [],
"detail": "CMake template build task"
},
{
"type": "cmake",
"label": "CMake: test",
"command": "test",
"problemMatcher": [],
"detail": "CMake template test task",
"group": "build"
},
{
"type": "cmake",
"label": "CMake: clean",
"command": "clean",
"problemMatcher": [],
"detail": "CMake template clean task",
"group": "build"
},
{
"type": "cmake",
"label": "CMake: clean rebuild",
"command": "cleanRebuild",
"targets": ["all"],
"problemMatcher": [],
"detail": "CMake template clean rebuild task",
"group": "build"
}
],
"version": "2.0.0"
}
+3 -5
View File
@@ -10,11 +10,7 @@ if (POLICY CMP0072)
set(OpenGL_GL_PREFERENCE LEGACY)
endif(POLICY CMP0072)
if (BUILD_WITH_CONDA AND WIN32)
option(FREECAD_USE_CCACHE "Auto detect and use ccache during compilation" OFF)
else()
option(FREECAD_USE_CCACHE "Auto detect and use ccache during compilation" ON)
endif()
option(FREECAD_USE_CCACHE "Auto detect and use ccache during compilation" ON)
if(FREECAD_USE_CCACHE)
find_program(CCACHE_PROGRAM ccache) #This check should occur before project()
@@ -107,6 +103,8 @@ if(MSVC AND FREECAD_LIBPACK_USE AND LIBPACK_FOUND)
endif()
if (ENABLE_DEVELOPER_TESTS)
include(CTest)
enable_testing()
add_subdirectory(tests)
endif()
+5 -5
View File
@@ -1,5 +1,5 @@
{
"version": 6,
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 14,
@@ -10,10 +10,6 @@
"name": "common",
"hidden": true,
"cacheVariables": {
"FREECAD_USE_PYBIND11": {
"type": "BOOL",
"value": "ON"
}
}
},
{
@@ -91,6 +87,10 @@
"type": "BOOL",
"value": "ON"
},
"FREECAD_USE_PYBIND11": {
"type": "BOOL",
"value": "ON"
},
"OCCT_CMAKE_FALLBACK": {
"type": "BOOL",
"value": "ON"
@@ -2,7 +2,7 @@ macro(ConfigureCMakeVariables)
# ================================================================================
# Output directories for install target
if(WIN32)
if(MSVC)
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "Installation root directory")
set(CMAKE_INSTALL_BINDIR bin CACHE PATH "Output directory for executables")
set(CMAKE_INSTALL_DATADIR data CACHE PATH "Output directory for data and resource files")
@@ -42,6 +42,13 @@ macro(SetGlobalCompilerAndLinkerSettings)
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /EHa")
endif()
endif(FREECAD_RELEASE_SEH)
if(CCACHE_PROGRAM)
# By default Visual Studio generators will use /Zi which is not compatible
# with ccache, so tell Visual Studio to use /Z7 instead.
string(REGEX REPLACE "/Z[iI]" "/Z7" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
string(REGEX REPLACE "/Z[iI]" "/Z7" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
string(REGEX REPLACE "/Z[iI]" "/Z7" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
endif(CCACHE_PROGRAM)
option(FREECAD_USE_MP_COMPILE_FLAG "Add /MP flag to the compiler definitions. Speeds up the compile on multi processor machines" ON)
if(FREECAD_USE_MP_COMPILE_FLAG)
+8
View File
@@ -69,6 +69,14 @@ if (Qt${FREECAD_QT_MAJOR_VERSION}Core_VERSION VERSION_LESS 5.15.0)
qt5_add_translation("${_qm_files}" ${ARGN})
set("${_qm_files}" "${${_qm_files}}" PARENT_SCOPE)
endfunction()
# Since Qt 5.15 Q_DISABLE_COPY_MOVE is defined
set (HAVE_Q_DISABLE_COPY_MOVE 0)
configure_file(${CMAKE_SOURCE_DIR}/src/QtCore.h.cmake ${CMAKE_BINARY_DIR}/src/QtCore.h)
else()
# Since Qt 5.15 Q_DISABLE_COPY_MOVE is defined
set (HAVE_Q_DISABLE_COPY_MOVE 1)
configure_file(${CMAKE_SOURCE_DIR}/src/QtCore.h.cmake ${CMAKE_BINARY_DIR}/src/QtCore.h)
endif()
function(qt_find_and_add_translation _qm_files _tr_dir _qm_dir)
+1 -1
View File
@@ -75,7 +75,7 @@ macro(SetupSalomeSMESH)
if(NOT FREECAD_USE_EXTERNAL_SMESH)
find_package(MEDFile REQUIRED)
# See https://www.hdfgroup.org/HDF5/release/cmakebuild.html
if (WIN32)
if (MSVC)
find_package(HDF5 COMPONENTS NO_MODULE REQUIRED static)
else()
find_package(PkgConfig)
+6 -4
View File
@@ -57,21 +57,23 @@ dependencies:
- sed # [unix]
- boost
- boost-cpp
- ccache
- cmake
- coin3d
- coin3d==4.0.0
- compilers
- conda-build
- conda
- conda-devenv
- conda-smithy
- debugpy
- doxygen
- eigen
- fmt
- freetype
- git
- gmsh
- graphviz
- hdf5
- libcxx
- mamba==1.4.9
- matplotlib
- ninja
- numpy
@@ -96,4 +98,4 @@ dependencies:
- vtk
- xerces-c
- yaml-cpp
- zlib
- zlib
+1 -1
View File
@@ -4,7 +4,7 @@ call mamba env create -p .conda/freecad -f conda/conda-env.yaml
:: add the environment subdirectory to the conda configuration
call conda config --add envs_dirs %CONDA_PREFIX%/envs
call conda config --add envs_dirs %CD%/.conda
call conda config --set env_prompt '({name})'
call conda config --set env_prompt "({name})"
:: install the FreeCAD dependencies into the environment
call mamba run --live-stream -n freecad mamba-devenv -f conda/environment.devenv.yml
+1 -1
View File
@@ -6,7 +6,7 @@ mamba env create -p .conda/freecad -f conda/conda-env.yaml
# add the environment subdirectory to the conda configuration
conda config --add envs_dirs $CONDA_PREFIX/envs
conda config --add envs_dirs $(pwd)/.conda
conda config --set env_prompt '({name})'
conda config --set env_prompt "({name})"
# install the FreeCAD dependencies into the environment
mamba run --live-stream -n freecad mamba-devenv -f conda/environment.devenv.yml
+27
View File
@@ -0,0 +1,27 @@
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"configurationProvider": "ms-vscode.cmake-tools"
},
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**"
],
"configurationProvider": "ms-vscode.cmake-tools"
},
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/usr/include/**"
],
"configurationProvider": "ms-vscode.cmake-tools"
}
],
"version": 4
}
+94
View File
@@ -0,0 +1,94 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug C++ Tests",
"type": "cppdbg",
"request": "launch",
"cwd": "${workspaceFolder}",
"program": "${command:cmake.buildDirectory}/tests/Tests_run",
"args": [],
"environment": [
{
"name": "PATH",
"value": "${command:cmake.buildDirectory}/tests:${env:PATH}"
}
],
"linux": {
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb"
},
"osx": {
"MIMode": "lldb"
},
"stopAtEntry": false,
"externalConsole": false,
"preLaunchTask": "CMake: build",
"sourceFileMap": {
"${workspaceFolder}": "${workspaceFolder}"
}
},
{
"name": "C/C++ debugger",
"type": "cppdbg",
"request": "launch",
"cwd": "${workspaceFolder}",
"program": "${command:cmake.buildDirectory}/bin/FreeCAD",
"args": ["${workspaceFolder}/.vscode/scripts/VSCodeAutostartDebug.FCMacro"],
"environment": [
{
"name": "PATH",
"value": "${command:cmake.buildDirectory}/bin:${env:PATH}"
},
{
"name": "PYDEVD_DISABLE_FILE_VALIDATION",
"value": "1"
}
],
"linux": {
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb"
},
"osx": {
"MIMode": "lldb"
},
"stopAtEntry": false,
"externalConsole": false,
"presentation": {
"hidden": true,
}
},
{
"name": "Python debugger",
"type": "python",
"request": "attach",
"preLaunchTask": "WaitForDebugpy",
"redirectOutput": true,
"connect": {
"host": "localhost",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}/src",
"remoteRoot": "${command:cmake.buildDirectory}"
}
],
"justMyCode": false,
"presentation": {
"hidden": true,
}
}
],
"compounds": [
{
"name": "Debug FreeCAD",
"configurations": ["C/C++ debugger", "Python debugger"],
"preLaunchTask": "CMake: build",
"stopAll": true,
"presentation": {
"order": 1
}
}
]
}
+18
View File
@@ -0,0 +1,18 @@
import debugpy
from multiprocessing.connection import Listener
from freecad.utils import get_python_exe
# get_python_exe is needed because debugpy needs a python interpreter to work.
# It does not have to be FC embedded interpreter.
# By default it attempts to use Freecad's PID mistaking it for python.
# https://github.com/microsoft/debugpy/issues/262
debugpy.configure(python=get_python_exe())
debugpy.listen(('localhost', 5678))
# Turns out you cannot probe debugpy to see if it is up:
# https://github.com/microsoft/debugpy/issues/974
# Open another port that the script WaitForDebugpy can probe to see if
# debugpy is running
listener = Listener(('localhost', 6000), backlog=10)
debugpy.wait_for_client()
+29
View File
@@ -0,0 +1,29 @@
import socket
from contextlib import closing
import time
TIMEOUT_TIME_S = 30
RETRY_DELAY_S = 0.1
MAX_ATTEMPTS = TIMEOUT_TIME_S / RETRY_DELAY_S
def check_socket(host, port):
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock:
sock.settimeout(RETRY_DELAY_S)
return sock.connect_ex((host, port)) == 0
def main():
# DO NOT CHECK 5678 or debugpy will break
# Check other port manually opened instead
attempt_counter = 0
while (not check_socket('localhost', 6000)) and attempt_counter < MAX_ATTEMPTS:
time.sleep(RETRY_DELAY_S)
attempt_counter += 1
if attempt_counter >= MAX_ATTEMPTS:
exit(1)
else:
exit(0)
if __name__ == "__main__":
main()
+39
View File
@@ -0,0 +1,39 @@
{
// This disables vscode from adding lines to files.associations,
// some files might not be recognized though.
// This is a vscode issue.
"C_Cpp.autoAddFileAssociations": false,
"files.associations": {
"*.c": "c",
"*.h": "cpp",
"*.cpp": "cpp",
"*.hpp": "cpp",
"*.cxx": "cpp",
"*.hxx": "cpp",
"*.py": "python",
"*.FCMacro": "python"
},
"editor.formatOnType": true,
"files.autoSave": "afterDelay",
"debug.onTaskErrors": "abort", //to not launch the python debugger when waitforport.py fails
// Does not quick launch the debugger, forces to select debugger config every time
// Use the debug panel on the left instead
"debug.showInStatusBar": "never",
"cmake.options.advanced": {
"configurePreset": {
"statusBarVisibility": "visible"
},
"build": {
"statusBarVisibility": "visible"
},
"launch": {
"statusBarVisibility": "hidden"
},
"debug": {
"statusBarVisibility": "hidden"
}
}
}
+71
View File
@@ -0,0 +1,71 @@
{
"tasks": [
{
"type": "process",
"label": "FreeCAD: setup conda environment",
"linux": {
"command": "conda/setup-environment.sh",
},
"osx": {
"command": "conda/setup-environment.sh",
},
"windows": {
"command": "conda/setup-environment.cmd",
},
"group": "none",
"problemMatcher": [],
},
{
"label": "WaitForDebugpy",
"type": "shell",
"command": "python ${workspaceFolder}/.vscode/scripts/WaitForDebugpy.py",
"group": "none",
"problemMatcher": [],
"presentation": {
"reveal": "never", //silently fail and don't launch the debugger
"panel": "dedicated",
"close": true,
"revealProblems": "never"
},
"hide": true
},
{
"type": "cmake",
"label": "CMake: build",
"command": "build",
"preset": "${command:cmake.activeBuildPresetName}",
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Build all targets",
"dependsOn": [],
"problemMatcher": ["$gcc"]
},
{
"label": "Tests: run c++ tests",
"detail": "Run googletest",
"type": "shell",
"command": "${command:cmake.buildDirectory}/tests/Tests_run",
"group": {
"kind": "test",
"isDefault": true
},
"dependsOn": ["CMake: build"],
"problemMatcher": []
},
{
"label": "Tests: run python tests",
"detail": "Run FreeCAD integrated tests",
"type": "shell",
"command": "${command:cmake.buildDirectory}/bin/FreeCAD",
"args": ["-t", "0"],
"group": {
"kind": "test"
},
"dependsOn": ["CMake: build"],
"problemMatcher": []
}
],
"version": "2.0.0"
}
+1 -1
View File
@@ -10,7 +10,7 @@ opencamlib==2023.1.11
packaging==23.0
Pivy==0.6.8
ply==3.11
ptvsd==4.3.2
debugpy==1.6.7
pyNastran==1.3.4
pyshp==2.3.1
PySide2==5.15.2.1
+1 -1
View File
@@ -777,7 +777,7 @@ size_t BitpackIntegerDecoder<RegisterT>::inputProcessAligned( const char *inbuf,
destBuffer_->setNextInt64( value );
}
/// Store the result in next avaiable position in the user's dest buffer
/// Store the result in next available position in the user's dest buffer
/// Calc next bit alignment and which word it starts in
bitOffset += bitsPerRecord_;
+21 -10
View File
@@ -45,6 +45,17 @@
#include <map>
#include <set>
#if defined(__MINGW32__)
#define SMESH_EXPORT_MINGW SMESH_EXPORT
#define SMESH_EXPORT_MSVC
#elif defined(_MSC_VER)
#define SMESH_EXPORT_MINGW
#define SMESH_EXPORT_MSVC SMESH_EXPORT
#else
#define SMESH_EXPORT_MSVC
#define SMESH_EXPORT_MINGW
#endif
class SMDS_MeshFace;
class SMDS_MeshNode;
class gp_Ax1;
@@ -74,7 +85,7 @@ public:
SMESH_ComputeErrorPtr & GetError() { return myError; }
// --------------------------------------------------------------------------------
struct ElemFeatures //!< Features of element to create
struct SMESH_EXPORT_MINGW ElemFeatures //!< Features of element to create
{
SMDSAbs_ElementType myType;
bool myIsPoly, myIsQuad;
@@ -82,28 +93,28 @@ public:
double myBallDiameter;
std::vector<int> myPolyhedQuantities;
SMESH_EXPORT ElemFeatures( SMDSAbs_ElementType type=SMDSAbs_All, bool isPoly=false, bool isQuad=false )
SMESH_EXPORT_MSVC ElemFeatures( SMDSAbs_ElementType type=SMDSAbs_All, bool isPoly=false, bool isQuad=false )
:myType( type ), myIsPoly(isPoly), myIsQuad(isQuad), myID(-1), myBallDiameter(0) {}
SMESH_EXPORT ElemFeatures& Init( SMDSAbs_ElementType type, bool isPoly=false, bool isQuad=false )
SMESH_EXPORT_MSVC ElemFeatures& Init( SMDSAbs_ElementType type, bool isPoly=false, bool isQuad=false )
{ myType = type; myIsPoly = isPoly; myIsQuad = isQuad; return *this; }
SMESH_EXPORT ElemFeatures& Init( const SMDS_MeshElement* elem, bool basicOnly=true );
SMESH_EXPORT_MSVC ElemFeatures& Init( const SMDS_MeshElement* elem, bool basicOnly=true );
SMESH_EXPORT ElemFeatures& Init( double diameter )
SMESH_EXPORT_MSVC ElemFeatures& Init( double diameter )
{ myType = SMDSAbs_Ball; myBallDiameter = diameter; return *this; }
SMESH_EXPORT ElemFeatures& Init( std::vector<int>& quanities, bool isQuad=false )
SMESH_EXPORT_MSVC ElemFeatures& Init( std::vector<int>& quanities, bool isQuad=false )
{ myType = SMDSAbs_Volume; myIsPoly = 1; myIsQuad = isQuad;
myPolyhedQuantities.swap( quanities ); return *this; }
SMESH_EXPORT ElemFeatures& Init( const std::vector<int>& quanities, bool isQuad=false )
SMESH_EXPORT_MSVC ElemFeatures& Init( const std::vector<int>& quanities, bool isQuad=false )
{ myType = SMDSAbs_Volume; myIsPoly = 1; myIsQuad = isQuad;
myPolyhedQuantities = quanities; return *this; }
SMESH_EXPORT ElemFeatures& SetPoly(bool isPoly) { myIsPoly = isPoly; return *this; }
SMESH_EXPORT ElemFeatures& SetQuad(bool isQuad) { myIsQuad = isQuad; return *this; }
SMESH_EXPORT ElemFeatures& SetID (int ID) { myID = ID; return *this; }
SMESH_EXPORT_MSVC ElemFeatures& SetPoly(bool isPoly) { myIsPoly = isPoly; return *this; }
SMESH_EXPORT_MSVC ElemFeatures& SetQuad(bool isQuad) { myIsQuad = isQuad; return *this; }
SMESH_EXPORT_MSVC ElemFeatures& SetID (int ID) { myID = ID; return *this; }
};
/*!
-4
View File
@@ -39,10 +39,6 @@
#define SMDS_EXPORT
#endif
#ifdef VTK_HAS_MTIME_TYPE
#define VTK_MTIME_TYPE vtkMTimeType
#else
#define VTK_MTIME_TYPE unsigned long
#endif
#endif
@@ -1026,7 +1026,12 @@ void SMDS_UnstructuredGrid::BuildLinks()
GetLinks()->Allocate(this->GetNumberOfPoints());
GetLinks()->Register(this);
//FIXME: vtk9
#if VTK_VERSION_NUMBER < VTK_VERSION_CHECK(9,3,0)
GetLinks()->BuildLinks(this);
#else
GetLinks()->SetDataSet(this);
GetLinks()->BuildLinks();
#endif
GetLinks()->Delete();
#else
this->Links = SMDS_CellLinks::New();
+8 -9
View File
@@ -1215,7 +1215,7 @@ std::set<DocumentObject *> Application::getLinksTo(
} else {
std::set<Document*> docs;
for(auto o : obj->getInList()) {
if(o && o->getNameInDocument() && docs.insert(o->getDocument()).second) {
if(o && o->isAttachedToDocument() && docs.insert(o->getDocument()).second) {
o->getDocument()->getLinksTo(links,obj,options,maxCount);
if(maxCount && (int)links.size()>=maxCount)
break;
@@ -1808,7 +1808,7 @@ void segmentation_fault_handler(int sig)
#if defined(FC_DEBUG)
abort();
#else
exit(1);
_exit(1);
#endif
#else
switch (sig) {
@@ -2960,14 +2960,13 @@ void Application::LoadParameters()
}
}
#if defined(_MSC_VER)
// fix weird error while linking boost (all versions of VC)
// VS2010: https://forum.freecad.org/viewtopic.php?f=4&t=1886&p=12553&hilit=boost%3A%3Afilesystem%3A%3Aget#p12553
namespace boost { namespace program_options { std::string arg="arg"; } }
namespace boost { namespace program_options {
#if defined(_MSC_VER) && BOOST_VERSION < 108300
// fix weird error while linking boost (all versions of VC)
// VS2010: https://forum.freecad.org/viewtopic.php?f=4&t=1886&p=12553&hilit=boost%3A%3Afilesystem%3A%3Aget#p12553
namespace boost { namespace program_options { std::string arg="arg"; } }
namespace boost { namespace program_options {
const unsigned options_description::m_default_line_length = 80;
} }
} }
#endif
// A helper function to simplify the main part.
+4 -4
View File
@@ -186,9 +186,9 @@ PyMethodDef Application::Methods[] = {
PyObject* Application::sLoadFile(PyObject * /*self*/, PyObject *args)
{
char *path;
char *doc="";
char *mod="";
const char *path;
const char *doc="";
const char *mod="";
if (!PyArg_ParseTuple(args, "s|ss", &path, &doc, &mod))
return nullptr;
try {
@@ -398,7 +398,7 @@ PyObject* Application::sGetParam(PyObject * /*self*/, PyObject *args)
PyObject* Application::sSaveParameter(PyObject * /*self*/, PyObject *args)
{
char *pstr = "User parameter";
const char *pstr = "User parameter";
if (!PyArg_ParseTuple(args, "|s", &pstr))
return nullptr;
+315 -71
View File
@@ -24,10 +24,10 @@
***************************************************************************/
#include "PreCompiled.h"// NOLINT
#include "PreCompiled.h" // NOLINT
#ifndef _PreComp_
# include <cstdlib>
#include <cstdlib>
#endif
#include <boost/regex.hpp>
@@ -38,17 +38,20 @@
#include <Base/BoundBox.h>
#include <Base/Placement.h>
#include <Base/Reader.h>
#include <Base/Rotation.h>
#include <Base/Writer.h>
#include <boost/iostreams/device/array.hpp>
#include <boost/iostreams/stream.hpp>
using namespace Data;
TYPESYSTEM_SOURCE_ABSTRACT(Data::Segment , Base::BaseClass)// NOLINT
TYPESYSTEM_SOURCE_ABSTRACT(Data::ComplexGeoData , Base::Persistence)// NOLINT
TYPESYSTEM_SOURCE_ABSTRACT(Data::Segment, Base::BaseClass) // NOLINT
TYPESYSTEM_SOURCE_ABSTRACT(Data::ComplexGeoData, Base::Persistence) // NOLINT
FC_LOG_LEVEL_INIT("ComplexGeoData", true,true)// NOLINT
FC_LOG_LEVEL_INIT("ComplexGeoData", true, true) // NOLINT
namespace bio = boost::iostreams;
using namespace Data;
@@ -75,7 +78,7 @@ std::pair<std::string, unsigned long> ComplexGeoData::getTypeAndIndex(const char
Data::Segment* ComplexGeoData::getSubElementByName(const char* name) const
{
auto type = getTypeAndIndex(name);
return getSubElement(type.first.c_str(),type.second);
return getSubElement(type.first.c_str(), type.second);
}
void ComplexGeoData::applyTransform(const Base::Matrix4D& rclTrf)
@@ -106,10 +109,7 @@ Base::Placement ComplexGeoData::getPlacement() const
{
Base::Matrix4D mat = getTransform();
return {Base::Vector3d(mat[0][3],
mat[1][3],
mat[2][3]),
Base::Rotation(mat)};
return {Base::Vector3d(mat[0][3], mat[1][3], mat[2][3]), Base::Rotation(mat)};
}
double ComplexGeoData::getAccuracy() const
@@ -118,8 +118,8 @@ double ComplexGeoData::getAccuracy() const
}
void ComplexGeoData::getLinesFromSubElement(const Segment* segment,
std::vector<Base::Vector3d> &Points,
std::vector<Line> &lines) const
std::vector<Base::Vector3d>& Points,
std::vector<Line>& lines) const
{
(void)segment;
(void)Points;
@@ -127,9 +127,9 @@ void ComplexGeoData::getLinesFromSubElement(const Segment* segment,
}
void ComplexGeoData::getFacesFromSubElement(const Segment* segment,
std::vector<Base::Vector3d> &Points,
std::vector<Base::Vector3d> &PointNormals,
std::vector<Facet> &faces) const
std::vector<Base::Vector3d>& Points,
std::vector<Base::Vector3d>& PointNormals,
std::vector<Facet>& faces) const
{
(void)segment;
(void)Points;
@@ -145,9 +145,10 @@ Base::Vector3d ComplexGeoData::getPointFromLineIntersection(const Base::Vector3f
return Base::Vector3d();
}
void ComplexGeoData::getPoints(std::vector<Base::Vector3d> &Points,
std::vector<Base::Vector3d> &Normals,
double Accuracy, uint16_t flags) const
void ComplexGeoData::getPoints(std::vector<Base::Vector3d>& Points,
std::vector<Base::Vector3d>& Normals,
double Accuracy,
uint16_t flags) const
{
(void)Points;
(void)Normals;
@@ -155,9 +156,10 @@ void ComplexGeoData::getPoints(std::vector<Base::Vector3d> &Points,
(void)flags;
}
void ComplexGeoData::getLines(std::vector<Base::Vector3d> &Points,
std::vector<Line> &lines,
double Accuracy, uint16_t flags) const
void ComplexGeoData::getLines(std::vector<Base::Vector3d>& Points,
std::vector<Line>& lines,
double Accuracy,
uint16_t flags) const
{
(void)Points;
(void)lines;
@@ -165,9 +167,10 @@ void ComplexGeoData::getLines(std::vector<Base::Vector3d> &Points,
(void)flags;
}
void ComplexGeoData::getFaces(std::vector<Base::Vector3d> &Points,
std::vector<Facet> &faces,
double Accuracy, uint16_t flags) const
void ComplexGeoData::getFaces(std::vector<Base::Vector3d>& Points,
std::vector<Facet>& faces,
double Accuracy,
uint16_t flags) const
{
(void)Points;
(void)faces;
@@ -181,27 +184,30 @@ bool ComplexGeoData::getCenterOfGravity(Base::Vector3d& unused) const
return false;
}
size_t ComplexGeoData::getElementMapSize(bool flush) const {
size_t ComplexGeoData::getElementMapSize(bool flush) const
{
if (flush) {
flushElementMap();
#ifdef _FC_MEM_TRACE
FC_MSG("memory size " << (_MemSize/1024/1024) << "MB, " << (_MemMaxSize/1024/1024));
for (auto &unit : _MemUnits)
FC_MSG("unit " << unit.first << ": " << unit.second.count << ", " << unit.second.maxcount);
FC_MSG("memory size " << (_MemSize / 1024 / 1024) << "MB, " << (_MemMaxSize / 1024 / 1024));
for (auto& unit : _MemUnits) {
FC_MSG("unit " << unit.first << ": " << unit.second.count << ", "
<< unit.second.maxcount);
}
#endif
}
return _elementMap ? _elementMap->size():0;
return _elementMap ? _elementMap->size() : 0;
}
MappedName ComplexGeoData::getMappedName(const IndexedName & element,
MappedName ComplexGeoData::getMappedName(const IndexedName& element,
bool allowUnmapped,
ElementIDRefs *sid) const
ElementIDRefs* sid) const
{
if (!element) {
return {};
}
flushElementMap();
if(!_elementMap) {
if (!_elementMap) {
if (allowUnmapped) {
return MappedName(element);
}
@@ -215,8 +221,7 @@ MappedName ComplexGeoData::getMappedName(const IndexedName & element,
return name;
}
IndexedName ComplexGeoData::getIndexedName(const MappedName & name,
ElementIDRefs *sid) const
IndexedName ComplexGeoData::getIndexedName(const MappedName& name, ElementIDRefs* sid) const
{
flushElementMap();
if (!name) {
@@ -230,25 +235,23 @@ IndexedName ComplexGeoData::getIndexedName(const MappedName & name,
}
Data::MappedElement
ComplexGeoData::getElementName(const char *name,
ElementIDRefs *sid,
bool copy) const
ComplexGeoData::getElementName(const char* name, ElementIDRefs* sid, bool copy) const
{
IndexedName element(name, getElementTypes());
if (element) {
return {getMappedName(element, false, sid), element};
}
const char * mapped = isMappedElement(name);
const char* mapped = isMappedElement(name);
if (mapped) {
name = mapped;
}
MappedElement result;
// Strip out the trailing '.XXXX' if any
const char *dot = strchr(name,'.');
if(dot) {
result.name = MappedName(name, dot - name);
const char* dot = strchr(name, '.');
if (dot) {
result.name = MappedName(name, static_cast<int>(dot - name));
}
else if (copy) {
result.name = name;
@@ -260,10 +263,11 @@ ComplexGeoData::getElementName(const char *name,
return result;
}
std::vector<std::pair<MappedName, ElementIDRefs> >
ComplexGeoData::getElementMappedNames(const IndexedName & element, bool needUnmapped) const {
std::vector<std::pair<MappedName, ElementIDRefs>>
ComplexGeoData::getElementMappedNames(const IndexedName& element, bool needUnmapped) const
{
flushElementMap();
if(_elementMap) {
if (_elementMap) {
auto res = _elementMap->findAll(element);
if (!res.empty()) {
return res;
@@ -276,9 +280,10 @@ ComplexGeoData::getElementMappedNames(const IndexedName & element, bool needUnma
return {std::make_pair(MappedName(element), ElementIDRefs())};
}
std::vector<MappedElement> ComplexGeoData::getElementMap() const {
std::vector<MappedElement> ComplexGeoData::getElementMap() const
{
flushElementMap();
if(!_elementMap) {
if (!_elementMap) {
return {};
}
return _elementMap->getAll();
@@ -293,40 +298,40 @@ ElementMapPtr ComplexGeoData::elementMap(bool flush) const
}
void ComplexGeoData::flushElementMap() const
{
}
{}
void ComplexGeoData::setElementMap(const std::vector<MappedElement> &map) {
_elementMap = std::make_shared<Data::ElementMap>(); // Get rid of the old one, if any, but make
// sure the memory exists for the new data.
for(auto &element : map) {
void ComplexGeoData::setElementMap(const std::vector<MappedElement>& map)
{
_elementMap = std::make_shared<Data::ElementMap>(); // Get rid of the old one, if any, but make
// sure the memory exists for the new data.
for (auto& element : map) {
_elementMap->setElementName(element.index, element.name, Tag);
}
}
char ComplexGeoData::elementType(const Data::MappedName &name) const
char ComplexGeoData::elementType(const Data::MappedName& name) const
{
if(!name) {
if (!name) {
return 0;
}
auto indexedName = getIndexedName(name);
if (indexedName) {
return elementType(indexedName);
}
char element_type=0;
if (name.findTagInElementName(nullptr,nullptr,nullptr,&element_type) < 0) {
char element_type = 0;
if (name.findTagInElementName(nullptr, nullptr, nullptr, &element_type) < 0) {
return elementType(name.toIndexedName());
}
return element_type;
}
char ComplexGeoData::elementType(const Data::IndexedName &element) const
char ComplexGeoData::elementType(const Data::IndexedName& element) const
{
if(!element) {
if (!element) {
return 0;
}
for(auto &type : getElementTypes()) {
if(boost::equals(element.getType(), type)) {
for (auto& type : getElementTypes()) {
if (boost::equals(element.getType(), type)) {
return type[0];
}
}
@@ -345,27 +350,28 @@ char ComplexGeoData::elementType(const Data::IndexedName &element) const
// c) Try to get the elementType based on the MappedName. Return it if found
// 3) Check to make sure the discovered type is in the list of types, and return its first
// character if so.
char ComplexGeoData::elementType(const char *name) const {
if(!name) {
char ComplexGeoData::elementType(const char* name) const
{
if (!name) {
return 0;
}
const char *type = nullptr;
const char* type = nullptr;
IndexedName element(name, getElementTypes());
if (element) {
type = element.getType();
}
else {
const char * mapped = isMappedElement(name);
const char* mapped = isMappedElement(name);
if (mapped) {
name = mapped;
}
MappedName mappedName;
const char *dot = strchr(name,'.');
if(dot) {
mappedName = MappedName(name, dot-name);
type = dot+1;
const char* dot = strchr(name, '.');
if (dot) {
mappedName = MappedName(name, static_cast<int>(dot - name));
type = dot + 1;
}
else {
mappedName = MappedName::fromRawData(name);
@@ -376,9 +382,9 @@ char ComplexGeoData::elementType(const char *name) const {
}
}
if(type && type[0]) {
for(auto &elementTypes : getElementTypes()) {
if(boost::starts_with(type, elementTypes)) {
if (type && (type[0] != 0)) {
for (auto& elementTypes : getElementTypes()) {
if (boost::starts_with(type, elementTypes)) {
return type[0];
}
}
@@ -386,4 +392,242 @@ char ComplexGeoData::elementType(const char *name) const {
return 0;
}
void ComplexGeoData::setPersistenceFileName(const char* filename) const
{
if (!filename) {
filename = "";
}
_persistenceName = filename;
}
void ComplexGeoData::Save(Base::Writer& writer) const
{
if (getElementMapSize() == 0U) {
writer.Stream() << writer.ind() << "<ElementMap/>\n";
return;
}
// Store some dummy map entry to trigger recompute in older version.
writer.Stream() << writer.ind() << R"(<ElementMap new="1" count="1">)"
<< R"(<Element key="Dummy" value="Dummy"/>)"
<< "</ElementMap>\n";
// New layout of element map, so we use new xml tag, ElementMap2
writer.Stream() << writer.ind() << "<ElementMap2";
if (!_persistenceName.empty()) {
writer.Stream() << " file=\"" << writer.addFile((_persistenceName + ".txt").c_str(), this)
<< "\"/>\n";
return;
}
writer.Stream() << " count=\"" << _elementMap->size() << "\">\n";
_elementMap->save(writer.beginCharStream(Base::CharStreamFormat::Raw) << '\n');
writer.endCharStream() << '\n';
writer.Stream() << writer.ind() << "</ElementMap2>\n";
}
void ComplexGeoData::Restore(Base::XMLReader& reader)
{
resetElementMap();
reader.readElement("ElementMap");
bool newTag = false;
if (reader.hasAttribute("new") && reader.getAttributeAsInteger("new") > 0) {
reader.readEndElement("ElementMap");
reader.readElement("ElementMap2");
newTag = true;
}
const char* file = "";
if (reader.hasAttribute("file")) {
reader.getAttribute("file");
}
if (*file != 0) {
reader.addFile(file, this);
return;
}
std::size_t count = 0;
if (reader.hasAttribute("count")) {
count = reader.getAttributeAsUnsigned("count");
}
if (count == 0) {
return;
}
if (newTag) {
resetElementMap(std::make_shared<ElementMap>());
_elementMap =
_elementMap->restore(Hasher, reader.beginCharStream(Base::CharStreamFormat::Raw));
reader.endCharStream();
reader.readEndElement("ElementMap2");
return;
}
if (reader.FileVersion > 1) {
restoreStream(reader.beginCharStream(Base::CharStreamFormat::Raw), count);
reader.endCharStream();
return;
}
readElements(reader, count);
reader.readEndElement("ElementMap");
}
void ComplexGeoData::readElements(Base::XMLReader& reader, size_t count)
{
size_t invalid_count = 0;
bool warned = false;
const auto& types = getElementTypes();
for (size_t i = 0; i < count; ++i) {
reader.readElement("Element");
ElementIDRefs sids;
if (reader.hasAttribute("sid")) {
if (!Hasher) {
if (!warned) {
warned = true;
FC_ERR("missing hasher"); // NOLINT
}
}
else {
const char* attr = reader.getAttribute("sid");
bio::stream<bio::array_source> iss(attr, std::strlen(attr));
long id {};
while ((iss >> id)) {
if (id == 0) {
continue;
}
auto sid = Hasher->getID(id);
if (!sid) {
++invalid_count;
}
else {
sids.push_back(sid);
}
char sep {};
iss >> sep;
}
}
}
_elementMap->setElementName(IndexedName(reader.getAttribute("value"), types),
MappedName(reader.getAttribute("key")),
Tag,
&sids);
}
if (invalid_count != 0) {
FC_ERR("Found " << invalid_count << " invalid string id"); // NOLINT
}
}
void ComplexGeoData::restoreStream(std::istream& stream, std::size_t count)
{
resetElementMap();
size_t invalid_count = 0;
std::string key;
std::string value;
std::string sid;
bool warned = false;
const auto& types = getElementTypes();
try {
for (size_t i = 0; i < count; ++i) {
ElementIDRefs sids;
std::size_t sCount = 0;
if (!(stream >> value >> key >> sCount)) {
// NOLINTNEXTLINE
FC_THROWM(Base::RuntimeError, "Failed to restore element map " << _persistenceName);
}
sids.reserve(static_cast<int>(sCount));
for (std::size_t j = 0; j < sCount; ++j) {
long id = 0;
if (!(stream >> id)) {
// NOLINTNEXTLINE
FC_THROWM(Base::RuntimeError,
"Failed to restore element map " << _persistenceName);
}
if (Hasher) {
auto hasherSID = Hasher->getID(id);
if (!hasherSID) {
++invalid_count;
}
else {
sids.push_back(hasherSID);
}
}
}
if (sCount != 0 && !Hasher) {
sids.clear();
if (!warned) {
warned = true;
FC_ERR("missing hasher"); // NOLINT
}
}
_elementMap->setElementName(IndexedName(value.c_str(), types),
MappedName(key),
Tag,
&sids);
}
}
catch (Base::Exception& e) {
e.ReportException();
_restoreFailed = true;
_elementMap.reset();
}
if (invalid_count != 0) {
FC_ERR("Found " << invalid_count << " invalid string id"); // NOLINT
}
}
void ComplexGeoData::SaveDocFile(Base::Writer& writer) const
{
flushElementMap();
if (_elementMap) {
writer.Stream() << "BeginElementMap v1\n";
_elementMap->save(writer.Stream());
}
}
void ComplexGeoData::RestoreDocFile(Base::Reader& reader)
{
std::string marker;
std::string ver;
reader >> marker;
if (boost::equals(marker, "BeginElementMap")) {
resetElementMap();
reader >> ver;
if (ver != "v1") {
FC_WARN("Unknown element map format"); // NOLINT
}
else {
resetElementMap(std::make_shared<ElementMap>());
_elementMap = _elementMap->restore(Hasher, reader);
return;
}
}
std::size_t count = atoi(marker.c_str());
restoreStream(reader, count);
}
unsigned int ComplexGeoData::getMemSize() const
{
flushElementMap();
if (_elementMap) {
static const int multiplier {10};
return _elementMap->size() * multiplier;
}
return 0;
}
void ComplexGeoData::beforeSave() const
{
flushElementMap();
if (this->_elementMap) {
this->_elementMap->beforeSave(Hasher);
}
}
// NOLINTEND(cppcoreguidelines-pro-bounds-pointer-arithmetic)
+20
View File
@@ -280,6 +280,19 @@ public:
virtual void flushElementMap() const;
//@}
/** @name Save/restore */
//@{
void Save (Base::Writer &writer) const override;
void Restore(Base::XMLReader &reader) override;
void SaveDocFile(Base::Writer &writer) const override;
void RestoreDocFile(Base::Reader &reader) override;
unsigned int getMemSize () const override;
void setPersistenceFileName(const char *name) const;
virtual void beforeSave() const;
bool isRestoreFailed() const { return _restoreFailed; }
void resetRestoreFailure() const { _restoreFailed = true; }
//@}
protected:
/// from local to outside
@@ -347,6 +360,9 @@ public:
protected:
void restoreStream(std::istream & stream, std::size_t count);
void readElements(Base::XMLReader& reader, size_t count);
/// from local to outside
inline Base::Vector3d transformToOutside(const Base::Vector3f& vec) const
{
@@ -370,6 +386,10 @@ protected:
private:
ElementMapPtr _elementMap;
protected:
mutable std::string _persistenceName;
mutable bool _restoreFailed = false;
};
} //namespace App
+24 -11
View File
@@ -93,6 +93,7 @@ recompute path. Also, it enables more complicated dependencies beyond trees.
#include <Base/Uuid.h>
#include <Base/Sequencer.h>
#include <Base/Stream.h>
#include <Base/UnitsApi.h>
#include "Document.h"
#include "private/DocumentP.h"
@@ -821,6 +822,18 @@ Document::Document(const char* documentName)
0,
Prop_None,
"Additional tag to save the name of the company");
ADD_PROPERTY_TYPE(UnitSystem, (""), 0, Prop_None, "Unit system to use in this project");
// Set up the possible enum values for the unit system
int num = static_cast<int>(Base::UnitSystem::NumUnitSystemTypes);
std::vector<std::string> enumValsAsVector;
for (int i = 0; i < num; i++) {
QString item = Base::UnitsApi::getDescription(static_cast<Base::UnitSystem>(i));
enumValsAsVector.emplace_back(item.toStdString());
}
UnitSystem.setEnums(enumValsAsVector);
// Get the preferences/General unit system as the default for a new document
ParameterGrp::handle hGrpu = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Units");
UnitSystem.setValue(hGrpu->GetInt("UserSchema", 0));
ADD_PROPERTY_TYPE(Comment, (""), 0, Prop_None, "Additional tag to save a comment");
ADD_PROPERTY_TYPE(Meta, (), 0, Prop_None, "Map with additional meta information");
ADD_PROPERTY_TYPE(Material, (), 0, Prop_None, "Map with material properties");
@@ -1113,7 +1126,7 @@ void Document::exportObjects(const std::vector<App::DocumentObject*>& obj, std::
if(FC_LOG_INSTANCE.isEnabled(FC_LOGLEVEL_LOG)) {
for(auto o : obj) {
if(o && o->getNameInDocument()) {
if(o && o->isAttachedToDocument()) {
FC_LOG("exporting " << o->getFullName());
if (!o->getPropertyByName("_ObjectUUID")) {
auto prop = static_cast<PropertyUUID*>(o->addDynamicProperty(
@@ -1479,7 +1492,7 @@ Document::importObjects(Base::XMLReader& reader)
std::vector<App::DocumentObject*> objs = readObjects(reader);
for(auto o : objs) {
if(o && o->getNameInDocument()) {
if(o && o->isAttachedToDocument()) {
o->setStatus(App::ObjImporting,true);
FC_LOG("importing " << o->getFullName());
if (auto propUUID = Base::freecad_dynamic_cast<PropertyUUID>(
@@ -1506,7 +1519,7 @@ Document::importObjects(Base::XMLReader& reader)
signalFinishImportObjects(objs);
for(auto o : objs) {
if(o && o->getNameInDocument())
if(o && o->isAttachedToDocument())
o->setStatus(App::ObjImporting,false);
}
@@ -1704,7 +1717,7 @@ private:
Base::FileInfo tmp(sourcename);
if (!tmp.renameFile(targetname.c_str())) {
throw Base::FileException(
"Cannot rename tmp save file to project file", targetname);
"Cannot rename tmp save file to project file", Base::FileInfo(targetname));
}
}
void applyTimeStamp(const std::string& sourcename, const std::string& targetname) {
@@ -2411,7 +2424,7 @@ static void _buildDependencyList(const std::vector<App::DocumentObject*> &object
while(!objs.empty()) {
auto obj = objs.front();
objs.pop_front();
if(!obj || !obj->getNameInDocument())
if(!obj || !obj->isAttachedToDocument())
continue;
auto it = outLists.find(obj);
@@ -2438,7 +2451,7 @@ static void _buildDependencyList(const std::vector<App::DocumentObject*> &object
if(objectMap && depList) {
for (const auto &v : outLists) {
for(auto obj : v.second) {
if(obj && obj->getNameInDocument())
if(obj && obj->isAttachedToDocument())
add_edge((*objectMap)[v.first],(*objectMap)[obj],*depList);
}
}
@@ -2833,7 +2846,7 @@ int Document::recompute(const std::vector<App::DocumentObject*> &objs, bool forc
FC_LOG("Recompute pass " << passes);
for (; idx < topoSortedObjects.size(); ++idx) {
auto obj = topoSortedObjects[idx];
if(!obj->getNameInDocument() || filter.find(obj)!=filter.end())
if(!obj->isAttachedToDocument() || filter.find(obj)!=filter.end())
continue;
// ask the object if it should be recomputed
bool doRecompute = false;
@@ -2890,7 +2903,7 @@ int Document::recompute(const std::vector<App::DocumentObject*> &objs, bool forc
FC_TIME_LOG(t2, "Recompute");
for(auto obj : topoSortedObjects) {
if(!obj->getNameInDocument())
if(!obj->isAttachedToDocument())
continue;
obj->setStatus(ObjectStatus::PendingRecompute,false);
obj->setStatus(ObjectStatus::Recompute2,false);
@@ -3051,8 +3064,8 @@ std::vector<App::DocumentObject*> DocumentP::topologicalSort(const std::vector<A
for (auto objectIt : objects) {
// We now support externally linked objects
// if(!obj->getNameInDocument() || obj->getDocument()!=this)
if(!objectIt->getNameInDocument())
// if(!obj->isAttachedToDocument() || obj->getDocument()!=this)
if(!objectIt->isAttachedToDocument())
continue;
//we need inlist with unique entries
auto in = objectIt->getInList();
@@ -3166,7 +3179,7 @@ bool Document::recomputeFeature(DocumentObject* Feat, bool recursive)
d->clearRecomputeLog(Feat);
// verify that the feature is (active) part of the document
if (Feat->getNameInDocument()) {
if (Feat->isAttachedToDocument()) {
if(recursive) {
bool hasError = false;
recompute({Feat},true,&hasError);
+2
View File
@@ -93,6 +93,8 @@ public:
PropertyString LastModifiedDate;
/// company name UTF8(optional)
PropertyString Company;
/// Unit System
PropertyEnumeration UnitSystem;
/// long comment or description (UTF8 with line breaks)
PropertyString Comment;
/// Id e.g. Part number
+11 -11
View File
@@ -274,7 +274,7 @@ const char* DocumentObject::getStatusString() const
}
std::string DocumentObject::getFullName() const {
if(!getDocument() || !pcNameInDocument)
if(!getDocument() || !isAttachedToDocument())
return "?";
std::string name(getDocument()->getName());
name += '#';
@@ -305,13 +305,13 @@ const char *DocumentObject::getNameInDocument() const
}
int DocumentObject::isExporting() const {
if(!getDocument() || !getNameInDocument())
if(!getDocument() || !isAttachedToDocument())
return 0;
return getDocument()->isExporting(this);
}
std::string DocumentObject::getExportName(bool forced) const {
if(!pcNameInDocument)
if(!isAttachedToDocument())
return {};
if(!forced && !isExporting())
@@ -441,7 +441,7 @@ void DocumentObject::getInListEx(std::set<App::DocumentObject*> &inSet,
// outLists first here.
for(auto doc : GetApplication().getDocuments()) {
for(auto obj : doc->getObjects()) {
if(!obj || !obj->getNameInDocument() || obj==this)
if(!obj || !obj->isAttachedToDocument() || obj==this)
continue;
const auto &outList = obj->getOutList();
outLists[obj].insert(outList.begin(),outList.end());
@@ -481,7 +481,7 @@ void DocumentObject::getInListEx(std::set<App::DocumentObject*> &inSet,
auto obj = pendings.top();
pendings.pop();
for(auto o : obj->getInList()) {
if(o && o->getNameInDocument() && inSet.insert(o).second) {
if(o && o->isAttachedToDocument() && inSet.insert(o).second) {
pendings.push(o);
if(inList)
inList->push_back(o);
@@ -839,7 +839,7 @@ std::vector<DocumentObject*> DocumentObject::getSubObjectList(const char *subnam
char c = sub[pos+1];
sub[pos+1] = 0;
auto sobj = getSubObject(sub.c_str());
if(!sobj || !sobj->getNameInDocument())
if(!sobj || !sobj->isAttachedToDocument())
break;
res.push_back(sobj);
sub[pos+1] = c;
@@ -859,14 +859,14 @@ std::vector<std::string> DocumentObject::getSubObjects(int reason) const {
std::vector<std::pair<App::DocumentObject *,std::string>> DocumentObject::getParents(int depth) const {
std::vector<std::pair<App::DocumentObject *, std::string>> ret;
if (!getNameInDocument() || !GetApplication().checkLinkDepth(depth, MessageOption::Throw)) {
if (!isAttachedToDocument() || !GetApplication().checkLinkDepth(depth, MessageOption::Throw)) {
return ret;
}
std::string name(getNameInDocument());
name += ".";
for (auto parent : getInList()) {
if (!parent || !parent->getNameInDocument()) {
if (!parent || !parent->isAttachedToDocument()) {
continue;
}
@@ -927,7 +927,7 @@ DocumentObject *DocumentObject::getLinkedObject(
void DocumentObject::Save (Base::Writer &writer) const
{
if (this->getNameInDocument())
if (this->isAttachedToDocument())
writer.ObjectName = this->getNameInDocument();
App::ExtensionContainer::Save(writer);
}
@@ -1164,7 +1164,7 @@ DocumentObject *DocumentObject::resolve(const char *subname,
DocumentObject *DocumentObject::resolveRelativeLink(std::string &subname,
DocumentObject *&link, std::string &linkSub) const
{
if(!link || !link->getNameInDocument() || !getNameInDocument())
if(!link || !link->isAttachedToDocument() || !isAttachedToDocument())
return nullptr;
auto ret = const_cast<DocumentObject*>(this);
if(link != ret) {
@@ -1268,6 +1268,6 @@ bool DocumentObject::redirectSubName(std::ostringstream &, DocumentObject *, Doc
void DocumentObject::onPropertyStatusChanged(const Property &prop, unsigned long oldStatus) {
(void)oldStatus;
if(!Document::isAnyRestoring() && getNameInDocument() && getDocument())
if(!Document::isAnyRestoring() && isAttachedToDocument() && getDocument())
getDocument()->signalChangePropertyEditor(*getDocument(),prop);
}
+1 -1
View File
@@ -153,7 +153,7 @@ DocumentObjectT &DocumentObjectT::operator=(DocumentObjectT&& obj)
void DocumentObjectT::operator=(const DocumentObject* obj)
{
if(!obj || !obj->getNameInDocument()) {
if(!obj || !obj->isAttachedToDocument()) {
object.clear();
label.clear();
document.clear();
+9 -4
View File
@@ -43,16 +43,21 @@ using namespace App;
PyObject* DocumentPy::addProperty(PyObject *args, PyObject *kwd)
{
char *sType,*sName=nullptr,*sGroup=nullptr,*sDoc=nullptr;
char *sType {nullptr};
char *sName {nullptr};
char *sGroup {nullptr};
char *sDoc {nullptr};
short attr=0;
std::string sDocStr;
PyObject *ro = Py_False, *hd = Py_False;
PyObject* enumVals = nullptr;
static char *kwlist[] = {"type","name","group","doc","attr","read_only","hidden","enum_vals",nullptr};
if (!PyArg_ParseTupleAndKeywords(
static const std::array<const char *, 9> kwlist{"type", "name", "group", "doc", "attr",
"read_only", "hidden", "enum_vals", nullptr};
if (!Base::Wrapped_ParseTupleAndKeywords(
args, kwd, "ss|sethO!O!O", kwlist, &sType, &sName, &sGroup, "utf-8",
&sDoc, &attr, &PyBool_Type, &ro, &PyBool_Type, &hd, &enumVals))
&sDoc, &attr, &PyBool_Type, &ro, &PyBool_Type, &hd, &enumVals)) {
return nullptr;
}
if (sDoc) {
sDocStr = sDoc;
+1 -1
View File
@@ -303,7 +303,7 @@ Crt = FreeCAD.Console.PrintCritical
Ntf = FreeCAD.Console.PrintNotification
Tnf = FreeCAD.Console.PrintTranslatedNotification
#store the cmake variales
#store the cmake variables
App.__cmake__ = cmake;
#store unit test names
+1 -1
View File
@@ -97,7 +97,7 @@ DocumentObject *GeoFeature::resolveElement(DocumentObject *obj, const char *subn
ElementNameType type, const DocumentObject *filter,
const char **_element, GeoFeature **geoFeature)
{
if(!obj || !obj->getNameInDocument())
if(!obj || !obj->isAttachedToDocument())
return nullptr;
if(!subname)
subname = "";
+1 -1
View File
@@ -489,7 +489,7 @@ void GeoFeatureGroupExtension::getInvalidLinkObjects(const DocumentObject* obj,
bool GeoFeatureGroupExtension::extensionGetSubObjects(std::vector<std::string> &ret, int) const {
for(auto obj : Group.getValues()) {
if(obj && obj->getNameInDocument() && !obj->testStatus(ObjectStatus::GeoExcluded))
if(obj && obj->isAttachedToDocument() && !obj->testStatus(ObjectStatus::GeoExcluded))
ret.push_back(std::string(obj->getNameInDocument())+'.');
}
return true;
+4 -4
View File
@@ -158,7 +158,7 @@ void GroupExtension::removeObjectsFromDocument()
void GroupExtension::removeObjectFromDocument(DocumentObject* obj)
{
// check that object is not invalid
if (!obj || !obj->getNameInDocument())
if (!obj || !obj->isAttachedToDocument())
return;
// remove all children
@@ -351,7 +351,7 @@ void GroupExtension::extensionOnChanged(const Property* p) {
if(p == &Group) {
_Conns.clear();
for(auto obj : Group.getValue()) {
if(obj && obj->getNameInDocument()) {
if(obj && obj->isAttachedToDocument()) {
//NOLINTBEGIN
_Conns[obj] = obj->signalChanged.connect(std::bind(
&GroupExtension::slotChildChanged,this,sp::_1, sp::_2));
@@ -398,7 +398,7 @@ bool GroupExtension::extensionGetSubObject(DocumentObject *&ret, const char *sub
bool GroupExtension::extensionGetSubObjects(std::vector<std::string> &ret, int) const {
for(auto obj : Group.getValues()) {
if(obj && obj->getNameInDocument())
if(obj && obj->isAttachedToDocument())
ret.push_back(std::string(obj->getNameInDocument())+'.');
}
return true;
@@ -421,7 +421,7 @@ void GroupExtension::getAllChildren(std::vector<App::DocumentObject*> &res,
std::set<App::DocumentObject*> &rset) const
{
for(auto obj : Group.getValues()) {
if(!obj || !obj->getNameInDocument())
if(!obj || !obj->isAttachedToDocument())
continue;
if(!rset.insert(obj).second)
continue;
+3 -3
View File
@@ -62,7 +62,7 @@ PyObject* GroupExtensionPy::addObject(PyObject *args)
return nullptr;
DocumentObjectPy* docObj = static_cast<DocumentObjectPy*>(object);
if (!docObj->getDocumentObjectPtr() || !docObj->getDocumentObjectPtr()->getNameInDocument()) {
if (!docObj->getDocumentObjectPtr() || !docObj->getDocumentObjectPtr()->isAttachedToDocument()) {
PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot add an invalid object");
return nullptr;
}
@@ -174,7 +174,7 @@ PyObject* GroupExtensionPy::removeObject(PyObject *args)
return nullptr;
DocumentObjectPy* docObj = static_cast<DocumentObjectPy*>(object);
if (!docObj->getDocumentObjectPtr() || !docObj->getDocumentObjectPtr()->getNameInDocument()) {
if (!docObj->getDocumentObjectPtr() || !docObj->getDocumentObjectPtr()->isAttachedToDocument()) {
PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot remove an invalid object");
return nullptr;
}
@@ -262,7 +262,7 @@ PyObject* GroupExtensionPy::hasObject(PyObject *args)
DocumentObjectPy* docObj = static_cast<DocumentObjectPy*>(object);
bool recursive = Base::asBoolean(recursivePy);
if (!docObj->getDocumentObjectPtr() || !docObj->getDocumentObjectPtr()->getNameInDocument()) {
if (!docObj->getDocumentObjectPtr() || !docObj->getDocumentObjectPtr()->isAttachedToDocument()) {
PyErr_SetString(Base::PyExc_FC_GeneralError, "Cannot check an invalid object");
return nullptr;
}
+15 -15
View File
@@ -518,7 +518,7 @@ void LinkBaseExtension::syncCopyOnChange()
// to match the possible new copy later.
objs = copyOnChangeGroup->ElementList.getValues();
for (auto obj : objs) {
if (!obj->getNameInDocument())
if (!obj->isAttachedToDocument())
continue;
auto prop = Base::freecad_dynamic_cast<PropertyUUID>(
obj->getPropertyByName("_SourceUUID"));
@@ -872,7 +872,7 @@ App::DocumentObject *LinkBaseExtension::makeCopyOnChange() {
if (auto prop = getLinkCopyOnChangeGroupProperty()) {
if (auto obj = prop->getValue()) {
if (obj->getNameInDocument() && obj->getDocument())
if (obj->isAttachedToDocument() && obj->getDocument())
obj->getDocument()->removeObject(obj->getNameInDocument());
}
auto group = new LinkGroup;
@@ -1088,7 +1088,7 @@ int LinkBaseExtension::getElementIndex(const char *subname, const char **psubnam
// pattern, which is the owner object name + "_i" + index
const char *name = subname[0]=='$'?subname+1:subname;
auto owner = getContainer();
if(owner && owner->getNameInDocument()) {
if(owner && owner->isAttachedToDocument()) {
std::string ownerName(owner->getNameInDocument());
ownerName += '_';
if(boost::algorithm::starts_with(name,ownerName.c_str())) {
@@ -1108,7 +1108,7 @@ int LinkBaseExtension::getElementIndex(const char *subname, const char **psubnam
// Then check for the actual linked object's name or label, and
// redirect that reference to the first array element
auto linked = getTrueLinkedObject(false);
if(!linked || !linked->getNameInDocument())
if(!linked || !linked->isAttachedToDocument())
return -1;
if(subname[0]=='$') {
CharRange sub(subname+1, dot);
@@ -1223,7 +1223,7 @@ Base::Matrix4D LinkBaseExtension::getTransform(bool transform) const {
bool LinkBaseExtension::extensionGetSubObjects(std::vector<std::string> &ret, int reason) const {
if(!getLinkedObjectProperty() && getElementListProperty()) {
for(auto obj : getElementListProperty()->getValues()) {
if(obj && obj->getNameInDocument()) {
if(obj && obj->isAttachedToDocument()) {
std::string name(obj->getNameInDocument());
name+='.';
ret.push_back(name);
@@ -1303,7 +1303,7 @@ bool LinkBaseExtension::extensionGetSubObject(DocumentObject *&ret, const char *
if(idx>=0) {
const auto &elements = _getElementListValue();
if(!elements.empty()) {
if(idx>=(int)elements.size() || !elements[idx] || !elements[idx]->getNameInDocument())
if(idx>=(int)elements.size() || !elements[idx] || !elements[idx]->isAttachedToDocument())
return true;
ret = elements[idx]->getSubObject(subname,pyObj,mat,true,depth+1);
// do not resolve the link if this element is the last referenced object
@@ -1415,7 +1415,7 @@ void LinkBaseExtension::onExtendedUnsetupObject() {
return;
detachElements();
if (auto obj = getLinkCopyOnChangeGroupValue()) {
if(obj->getNameInDocument() && !obj->isRemoving())
if(obj->isAttachedToDocument() && !obj->isRemoving())
obj->getDocument()->removeObject(obj->getNameInDocument());
}
}
@@ -1440,7 +1440,7 @@ DocumentObject *LinkBaseExtension::getTrueLinkedObject(
}
if(ret && recurse)
ret = ret->getLinkedObject(recurse,mat,transform,depth+1);
if(ret && !ret->getNameInDocument())
if(ret && !ret->isAttachedToDocument())
return nullptr;
return ret;
}
@@ -1514,7 +1514,7 @@ void LinkBaseExtension::updateGroup() {
groupSet.insert(group->getExtendedObject());
}else{
for(auto o : getElementListProperty()->getValues()) {
if(!o || !o->getNameInDocument())
if(!o || !o->isAttachedToDocument())
continue;
auto ext = o->getExtensionByType<GroupExtension>(true,false);
if(ext) {
@@ -1636,7 +1636,7 @@ void LinkBaseExtension::update(App::DocumentObject *parent, const Property *prop
getScaleListProperty()->setValue(scales);
for(auto obj : objs) {
if(obj && obj->getNameInDocument())
if(obj && obj->isAttachedToDocument())
obj->getDocument()->removeObject(obj->getNameInDocument());
}
}
@@ -1734,7 +1734,7 @@ void LinkBaseExtension::update(App::DocumentObject *parent, const Property *prop
}
getElementListProperty()->setValue(objs);
for(auto obj : tmpObjs) {
if(obj && obj->getNameInDocument())
if(obj && obj->isAttachedToDocument())
obj->getDocument()->removeObject(obj->getNameInDocument());
}
}
@@ -1859,7 +1859,7 @@ void LinkBaseExtension::cacheChildLabel(int enable) const {
int idx = 0;
for(auto child : _getElementListValue()) {
if(child && child->getNameInDocument())
if(child && child->isAttachedToDocument())
myLabelCache[child->Label.getStrValue()] = idx;
++idx;
}
@@ -2021,7 +2021,7 @@ void LinkBaseExtension::setLink(int index, DocumentObject *obj,
objs.push_back(elements[i]);
}
getElementListProperty()->setValue(objs);
}else if(!obj->getNameInDocument())
}else if(!obj->isAttachedToDocument())
LINK_THROW(Base::ValueError,"Invalid object");
else{
if(index>(int)elements.size())
@@ -2075,7 +2075,7 @@ void LinkBaseExtension::setLink(int index, DocumentObject *obj,
auto xlink = freecad_dynamic_cast<PropertyXLink>(linkProp);
if(obj) {
if(!obj->getNameInDocument())
if(!obj->isAttachedToDocument())
LINK_THROW(Base::ValueError,"Invalid document object");
if(!xlink) {
if(parent && obj->getDocument()!=parent->getDocument())
@@ -2113,7 +2113,7 @@ void LinkBaseExtension::detachElements()
}
void LinkBaseExtension::detachElement(DocumentObject *obj) {
if(!obj || !obj->getNameInDocument() || obj->isRemoving())
if(!obj || !obj->isAttachedToDocument() || obj->isRemoving())
return;
auto ext = obj->getExtensionByType<LinkBaseExtension>(true);
auto owner = getContainer();
+2 -2
View File
@@ -1421,7 +1421,7 @@ void ObjectIdentifier::setDocumentObjectName(ObjectIdentifier::String &&name, bo
void ObjectIdentifier::setDocumentObjectName(const App::DocumentObject *obj, bool force,
ObjectIdentifier::String &&subname, bool checkImport)
{
if(!owner || !obj || !obj->getNameInDocument() || !obj->getDocument())
if(!owner || !obj || !obj->isAttachedToDocument() || !obj->getDocument())
FC_THROWM(Base::RuntimeError,"invalid object");
if(checkImport)
@@ -1930,7 +1930,7 @@ bool ObjectIdentifier::isTouched() const {
}
void ObjectIdentifier::resolveAmbiguity() {
if(!owner || !owner->getNameInDocument() || isLocalProperty() ||
if(!owner || !owner->isAttachedToDocument() || isLocalProperty() ||
(documentObjectNameSet && !documentObjectName.getString().empty() &&
(documentObjectName.isRealString() || documentObjectName.isForceIdentifier())))
{
+2 -2
View File
@@ -117,9 +117,9 @@ public:
short mustExecute() const override;
/// Axis types
static constexpr char* AxisRoles[3] = {"X_Axis", "Y_Axis", "Z_Axis"};
static constexpr const char* AxisRoles[3] = {"X_Axis", "Y_Axis", "Z_Axis"};
/// Baseplane types
static constexpr char* PlaneRoles[3] = {"XY_Plane", "XZ_Plane", "YZ_Plane"};
static constexpr const char* PlaneRoles[3] = {"XY_Plane", "XZ_Plane", "YZ_Plane"};
// Axis links
PropertyLinkList OriginFeatures;
+1 -1
View File
@@ -71,7 +71,7 @@ bool OriginGroupExtension::extensionGetSubObject(DocumentObject *&ret, const cha
{
App::DocumentObject *originObj = Origin.getValue ();
const char *dot;
if(originObj && originObj->getNameInDocument() &&
if(originObj && originObj->isAttachedToDocument() &&
subname && (dot=strchr(subname,'.')))
{
bool found;
+1 -1
View File
@@ -286,7 +286,7 @@ PyObject* PropertyContainerPy::setPropertyStatus(PyObject *args)
PyObject* PropertyContainerPy::getPropertyStatus(PyObject *args)
{
char* name = "";
const char* name = "";
if (!PyArg_ParseTuple(args, "|s", &name))
return nullptr;
+1 -1
View File
@@ -129,7 +129,7 @@ Property *PropertyExpressionEngine::Copy() const
void PropertyExpressionEngine::hasSetValue()
{
App::DocumentObject *owner = dynamic_cast<App::DocumentObject*>(getContainer());
if(!owner || !owner->getNameInDocument() || owner->isRestoring() || testFlag(LinkDetached)) {
if(!owner || !owner->isAttachedToDocument() || owner->isRestoring() || testFlag(LinkDetached)) {
PropertyExpressionContainer::hasSetValue();
return;
}
+1 -1
View File
@@ -172,7 +172,7 @@ private:
using DiGraph = boost::adjacency_list< boost::listS, boost::vecS, boost::directedS >;
using Edge = std::pair<int, int>;
// Note: use std::map instead of unordered_map to keep the binding order stable
#if defined(FC_OS_MACOSX) || defined(FC_OS_BSD)
#if defined(FC_OS_MACOSX) || defined(FC_OS_BSD) || defined(_LIBCPP_VERSION)
using ExpressionMap = std::map<App::ObjectIdentifier, ExpressionInfo>;
#else
using ExpressionMap = std::map<const App::ObjectIdentifier, ExpressionInfo>;
+17
View File
@@ -36,6 +36,8 @@
#include <Base/VectorPy.h>
#include <Base/Writer.h>
#include "ComplexGeoData.h"
#include "Document.h"
#include "PropertyGeo.h"
#include "Placement.h"
#include "ObjectIdentifier.h"
@@ -1241,3 +1243,18 @@ TYPESYSTEM_SOURCE_ABSTRACT(App::PropertyComplexGeoData , App::PropertyGeometry)
PropertyComplexGeoData::PropertyComplexGeoData() = default;
PropertyComplexGeoData::~PropertyComplexGeoData() = default;
void PropertyComplexGeoData::afterRestore()
{
auto data = getComplexData();
if (data && data->isRestoreFailed()) {
data->resetRestoreFailure();
auto owner = Base::freecad_dynamic_cast<DocumentObject>(getContainer());
if (owner &&
owner->getDocument() &&
!owner->getDocument()->testStatus(App::Document::PartialDoc)) {
owner->getDocument()->addRecomputeObject(owner);
}
}
PropertyGeometry::afterRestore();
}
+2
View File
@@ -541,6 +541,8 @@ public:
virtual const Data::ComplexGeoData* getComplexData() const = 0;
Base::BoundBox3d getBoundingBox() const override = 0;
//@}
void afterRestore() override;
};
} // namespace App
+66 -66
View File
@@ -146,7 +146,7 @@ void PropertyLinkBase::checkLabelReferences(const std::vector<std::string> &subs
std::string PropertyLinkBase::updateLabelReference(const App::DocumentObject *parent,
const char *subname, App::DocumentObject *obj, const std::string &ref, const char *newLabel)
{
if(!obj || !obj->getNameInDocument() || !parent || !parent->getNameInDocument())
if(!obj || !obj->isAttachedToDocument() || !parent || !parent->isAttachedToDocument())
return {};
// Because the label is allowed to be the same across different
@@ -169,7 +169,7 @@ std::vector<std::pair<Property*, std::unique_ptr<Property> > >
PropertyLinkBase::updateLabelReferences(App::DocumentObject *obj, const char *newLabel)
{
std::vector<std::pair<Property*,std::unique_ptr<Property> > > ret;
if(!obj || !obj->getNameInDocument())
if(!obj || !obj->isAttachedToDocument())
return ret;
auto it = _LabelMap.find(obj->Label.getStrValue());
if(it == _LabelMap.end())
@@ -525,7 +525,7 @@ void PropertyLink::getLinks(std::vector<App::DocumentObject *> &objs,
{
(void)newStyle;
(void)subs;
if((all||_pcScope!=LinkScope::Hidden) && _pcLink && _pcLink->getNameInDocument())
if((all||_pcScope!=LinkScope::Hidden) && _pcLink && _pcLink->isAttachedToDocument())
objs.push_back(_pcLink);
}
@@ -594,7 +594,7 @@ void PropertyLinkList::setSize(int newSize)
{
for(int i=newSize;i<(int)_lValueList.size();++i) {
auto obj = _lValueList[i];
if (!obj || !obj->getNameInDocument())
if (!obj || !obj->isAttachedToDocument())
continue;
_nameMap.erase(obj->getNameInDocument());
#ifndef USE_OLD_DAG
@@ -620,7 +620,7 @@ void PropertyLinkList::set1Value(int idx, DocumentObject* const &value) {
return;
}
if(!value || !value->getNameInDocument())
if(!value || !value->isAttachedToDocument())
throw Base::ValueError("invalid document object");
_nameMap.clear();
@@ -651,7 +651,7 @@ void PropertyLinkList::setValues(const std::vector<DocumentObject*>& lValue) {
auto parent = Base::freecad_dynamic_cast<App::DocumentObject>(getContainer());
for(auto obj : lValue) {
if(!obj || !obj->getNameInDocument())
if(!obj || !obj->isAttachedToDocument())
throw Base::ValueError("PropertyLinkList: invalid document object");
if(!testFlag(LinkAllowExternal) && parent && parent->getDocument()!=obj->getDocument())
throw Base::ValueError("PropertyLinkList does not support external object");
@@ -688,7 +688,7 @@ PyObject *PropertyLinkList::getPyObject()
#endif
for (int i = 0; i<count; i++) {
auto obj = _lValueList[i];
if(obj && obj->getNameInDocument())
if(obj && obj->isAttachedToDocument())
sequence.setItem(i, Py::asObject(_lValueList[i]->getPyObject()));
else
sequence.setItem(i, Py::None());
@@ -818,7 +818,7 @@ DocumentObject *PropertyLinkList::find(const std::string &name, int *pindex) con
_nameMap.clear();
for(int i=0;i<(int)_lValueList.size();++i) {
auto obj = _lValueList[i];
if(obj && obj->getNameInDocument())
if(obj && obj->isAttachedToDocument())
_nameMap[obj->getNameInDocument()] = i;
}
}
@@ -837,7 +837,7 @@ void PropertyLinkList::getLinks(std::vector<App::DocumentObject *> &objs,
if(all||_pcScope!=LinkScope::Hidden) {
objs.reserve(objs.size()+_lValueList.size());
for(auto obj : _lValueList) {
if(obj && obj->getNameInDocument())
if(obj && obj->isAttachedToDocument())
objs.push_back(obj);
}
}
@@ -911,7 +911,7 @@ void PropertyLinkSub::setValue(App::DocumentObject * lValue,
{
auto parent = Base::freecad_dynamic_cast<App::DocumentObject>(getContainer());
if(lValue) {
if(!lValue->getNameInDocument())
if(!lValue->isAttachedToDocument())
throw Base::ValueError("PropertyLinkSub: invalid document object");
if(!testFlag(LinkAllowExternal) && parent && parent->getDocument()!=lValue->getDocument())
throw Base::ValueError("PropertyLinkSub does not support external object");
@@ -1067,7 +1067,7 @@ static bool updateLinkReference(App::PropertyLinkBase *prop,
prop->unregisterElementReference();
}
shadows.resize(subs.size());
if(!link || !link->getNameInDocument())
if(!link || !link->isAttachedToDocument())
return false;
auto owner = dynamic_cast<DocumentObject*>(prop->getContainer());
if(owner && owner->isRestoring())
@@ -1093,7 +1093,7 @@ static bool updateLinkReference(App::PropertyLinkBase *prop,
void PropertyLinkSub::afterRestore() {
_ShadowSubList.resize(_cSubList.size());
if(!testFlag(LinkRestoreLabel) ||!_pcLinkSub || !_pcLinkSub->getNameInDocument())
if(!testFlag(LinkRestoreLabel) ||!_pcLinkSub || !_pcLinkSub->isAttachedToDocument())
return;
setFlag(LinkRestoreLabel,false);
for(std::size_t i=0;i<_cSubList.size();++i)
@@ -1102,7 +1102,7 @@ void PropertyLinkSub::afterRestore() {
void PropertyLinkSub::onContainerRestored() {
unregisterElementReference();
if(!_pcLinkSub || !_pcLinkSub->getNameInDocument())
if(!_pcLinkSub || !_pcLinkSub->isAttachedToDocument())
return;
for(std::size_t i=0;i<_cSubList.size();++i)
_registerElementReference(_pcLinkSub,_cSubList[i],_ShadowSubList[i]);
@@ -1160,7 +1160,7 @@ const char *PropertyLinkBase::exportSubName(std::string &output,
doc = GetApplication().getDocument(std::string(sub,hash-sub).c_str());
else {
hash = nullptr;
if(obj && obj->getNameInDocument())
if(obj && obj->isAttachedToDocument())
doc = obj->getDocument();
}
if(!doc) {
@@ -1168,14 +1168,14 @@ const char *PropertyLinkBase::exportSubName(std::string &output,
return res;
}
obj = doc->getObject(std::string(sub,dot-sub).c_str());
if(!obj || !obj->getNameInDocument())
if(!obj || !obj->isAttachedToDocument())
return res;
if(hash) {
if(!obj->isExporting())
str << doc->getName() << '#';
sub = hash+1;
}
}else if(!obj || !obj->getNameInDocument())
}else if(!obj || !obj->isAttachedToDocument())
return res;
for(const char *dot=strchr(sub,'.');dot;sub=dot+1,dot=strchr(sub,'.')) {
@@ -1185,7 +1185,7 @@ const char *PropertyLinkBase::exportSubName(std::string &output,
first_obj = false;
else
obj = obj->getSubObject(name.c_str());
if(!obj || !obj->getNameInDocument()) {
if(!obj || !obj->isAttachedToDocument()) {
FC_WARN("missing sub object '" << name << "' in '" << sub <<"'");
break;
}
@@ -1214,7 +1214,7 @@ const char *PropertyLinkBase::exportSubName(std::string &output,
App::DocumentObject *PropertyLinkBase::tryImport(const App::Document *doc,
const App::DocumentObject *obj, const std::map<std::string,std::string> &nameMap)
{
if(doc && obj && obj->getNameInDocument()) {
if(doc && obj && obj->isAttachedToDocument()) {
auto it = nameMap.find(obj->getExportName(true));
if(it!=nameMap.end()) {
obj = doc->getObject(it->second.c_str());
@@ -1228,7 +1228,7 @@ App::DocumentObject *PropertyLinkBase::tryImport(const App::Document *doc,
std::string PropertyLinkBase::tryImportSubName(const App::DocumentObject *obj, const char *_subname,
const App::Document *doc, const std::map<std::string,std::string> &nameMap)
{
if(!doc || !obj || !obj->getNameInDocument())
if(!doc || !obj || !obj->isAttachedToDocument())
return {};
std::ostringstream ss;
@@ -1281,7 +1281,7 @@ void PropertyLinkSub::Save (Base::Writer &writer) const
std::string internal_name;
// it can happen that the object is still alive but is not part of the document anymore and thus
// returns 0
if (_pcLinkSub && _pcLinkSub->getNameInDocument())
if (_pcLinkSub && _pcLinkSub->isAttachedToDocument())
internal_name = _pcLinkSub->getExportName();
writer.Stream() << writer.ind() << "<LinkSub value=\""
<< internal_name <<"\" count=\"" << _cSubList.size();
@@ -1380,7 +1380,7 @@ template<class Func, class... Args >
std::vector<std::string> updateLinkSubs(const App::DocumentObject *obj,
const std::vector<std::string> &subs, Func *f, Args&&... args )
{
if(!obj || !obj->getNameInDocument())
if(!obj || !obj->isAttachedToDocument())
return {};
std::vector<std::string> res;
@@ -1405,7 +1405,7 @@ Property *PropertyLinkSub::CopyOnImportExternal(
auto owner = dynamic_cast<const DocumentObject*>(getContainer());
if(!owner || !owner->getDocument())
return nullptr;
if(!_pcLinkSub || !_pcLinkSub->getNameInDocument())
if(!_pcLinkSub || !_pcLinkSub->isAttachedToDocument())
return nullptr;
auto subs = updateLinkSubs(_pcLinkSub,_cSubList,
@@ -1429,7 +1429,7 @@ Property *PropertyLinkSub::CopyOnLabelChange(App::DocumentObject *obj,
auto owner = dynamic_cast<const DocumentObject*>(getContainer());
if(!owner || !owner->getDocument())
return nullptr;
if(!_pcLinkSub || !_pcLinkSub->getNameInDocument())
if(!_pcLinkSub || !_pcLinkSub->isAttachedToDocument())
return nullptr;
auto subs = updateLinkSubs(_pcLinkSub,_cSubList,&updateLabelReference,obj,ref,newLabel);
@@ -1475,7 +1475,7 @@ void PropertyLinkSub::getLinks(std::vector<App::DocumentObject *> &objs,
bool all, std::vector<std::string> *subs, bool newStyle) const
{
if(all||_pcScope!=LinkScope::Hidden) {
if(_pcLinkSub && _pcLinkSub->getNameInDocument()) {
if(_pcLinkSub && _pcLinkSub->isAttachedToDocument()) {
objs.push_back(_pcLinkSub);
if(subs)
*subs = getSubValues(newStyle);
@@ -1528,7 +1528,7 @@ static App::DocumentObject *adjustLinkSubs(App::PropertyLinkBase *prop,
bool PropertyLinkSub::adjustLink(const std::set<App::DocumentObject*> &inList) {
if (_pcScope==LinkScope::Hidden)
return false;
if(!_pcLinkSub || !_pcLinkSub->getNameInDocument() || !inList.count(_pcLinkSub))
if(!_pcLinkSub || !_pcLinkSub->isAttachedToDocument() || !inList.count(_pcLinkSub))
return false;
auto subs = _cSubList;
auto link = adjustLinkSubs(this,inList,_pcLinkSub,subs);
@@ -1581,7 +1581,7 @@ void PropertyLinkSubList::setSyncSubObject(bool enable)
void PropertyLinkSubList::verifyObject(App::DocumentObject* obj, App::DocumentObject* parent)
{
if (obj) {
if (!obj->getNameInDocument())
if (!obj->isAttachedToDocument())
throw Base::ValueError("PropertyLinkSubList: invalid document object");
if (!testFlag(LinkAllowExternal) && parent && parent->getDocument() != obj->getDocument())
throw Base::ValueError("PropertyLinkSubList does not support external object");
@@ -2104,7 +2104,7 @@ void PropertyLinkSubList::Save (Base::Writer &writer) const
int count = 0;
for(auto obj : _lValueList) {
if(obj && obj->getNameInDocument())
if(obj && obj->isAttachedToDocument())
++count;
}
writer.Stream() << writer.ind() << "<LinkSubList count=\"" << count <<"\">" << endl;
@@ -2113,7 +2113,7 @@ void PropertyLinkSubList::Save (Base::Writer &writer) const
bool exporting = owner && owner->isExporting();
for (int i = 0; i < getSize(); i++) {
auto obj = _lValueList[i];
if(!obj || !obj->getNameInDocument())
if(!obj || !obj->isAttachedToDocument())
continue;
const auto &shadow = _ShadowSubList[i];
// shadow.second stores the old style element name. For backward
@@ -2243,7 +2243,7 @@ Property *PropertyLinkSubList::CopyOnImportExternal(
for(auto itValue=_lValueList.begin();itValue!=_lValueList.end();++itValue,++itSub) {
auto value = *itValue;
const auto &sub = *itSub;
if(!value || !value->getNameInDocument()) {
if(!value || !value->isAttachedToDocument()) {
if(!values.empty()) {
values.push_back(value);
subs.push_back(sub);
@@ -2286,7 +2286,7 @@ Property *PropertyLinkSubList::CopyOnLabelChange(App::DocumentObject *obj,
for(auto itValue=_lValueList.begin();itValue!=_lValueList.end();++itValue,++itSub) {
auto value = *itValue;
const auto &sub = *itSub;
if(!value || !value->getNameInDocument()) {
if(!value || !value->isAttachedToDocument()) {
if(!values.empty()) {
values.push_back(value);
subs.push_back(sub);
@@ -2326,7 +2326,7 @@ Property *PropertyLinkSubList::CopyOnLinkReplace(const App::DocumentObject *pare
for(auto itValue=_lValueList.begin();itValue!=_lValueList.end();++itValue,++itSub) {
auto value = *itValue;
const auto &sub = *itSub;
if(!value || !value->getNameInDocument()) {
if(!value || !value->isAttachedToDocument()) {
if(!values.empty()) {
values.push_back(value);
subs.push_back(sub);
@@ -2420,7 +2420,7 @@ void PropertyLinkSubList::getLinks(std::vector<App::DocumentObject *> &objs,
if(all||_pcScope!=LinkScope::Hidden) {
objs.reserve(objs.size()+_lValueList.size());
for(auto obj : _lValueList) {
if(obj && obj->getNameInDocument())
if(obj && obj->isAttachedToDocument())
objs.push_back(obj);
}
if(subs) {
@@ -2466,7 +2466,7 @@ bool PropertyLinkSubList::adjustLink(const std::set<App::DocumentObject*> &inLis
for(std::string &sub : subs) {
++idx;
auto &link = links[idx];
if(!link || !link->getNameInDocument() || !inList.count(link))
if(!link || !link->isAttachedToDocument() || !inList.count(link))
continue;
touched = true;
size_t pos = sub.find('.');
@@ -2988,7 +2988,7 @@ void PropertyXLink::restoreLink(App::DocumentObject *lValue) {
assert(!_pcLink && lValue && docInfo);
auto owner = dynamic_cast<DocumentObject*>(getContainer());
if(!owner || !owner->getNameInDocument())
if(!owner || !owner->isAttachedToDocument())
throw Base::RuntimeError("invalid container");
bool touched = owner->isTouched();
@@ -3020,13 +3020,13 @@ void PropertyXLink::setValue(App::DocumentObject *lValue,
if(_pcLink==lValue && _SubList==subs)
return;
if(lValue && (!lValue->getNameInDocument() || !lValue->getDocument())) {
if(lValue && (!lValue->isAttachedToDocument() || !lValue->getDocument())) {
throw Base::ValueError("Invalid object");
return;
}
auto owner = dynamic_cast<DocumentObject*>(getContainer());
if(!owner || !owner->getNameInDocument())
if(!owner || !owner->isAttachedToDocument())
throw Base::RuntimeError("invalid container");
if(lValue == owner)
@@ -3083,7 +3083,7 @@ void PropertyXLink::setValue(std::string &&filename, std::string &&name,
return;
}
auto owner = dynamic_cast<DocumentObject*>(getContainer());
if(!owner || !owner->getNameInDocument())
if(!owner || !owner->isAttachedToDocument())
throw Base::RuntimeError("invalid container");
DocumentObject *pObject=nullptr;
@@ -3199,7 +3199,7 @@ int PropertyXLink::checkRestore(std::string *msg) const {
void PropertyXLink::afterRestore() {
assert(_SubList.size() == _ShadowSubList.size());
if(!testFlag(LinkRestoreLabel) || !_pcLink || !_pcLink->getNameInDocument())
if(!testFlag(LinkRestoreLabel) || !_pcLink || !_pcLink->isAttachedToDocument())
return;
setFlag(LinkRestoreLabel,false);
for(size_t i=0;i<_SubList.size();++i)
@@ -3207,7 +3207,7 @@ void PropertyXLink::afterRestore() {
}
void PropertyXLink::onContainerRestored() {
if(!_pcLink || !_pcLink->getNameInDocument())
if(!_pcLink || !_pcLink->isAttachedToDocument())
return;
for(size_t i=0;i<_SubList.size();++i)
_registerElementReference(_pcLink,_SubList[i],_ShadowSubList[i]);
@@ -3411,7 +3411,7 @@ Property *PropertyXLink::CopyOnImportExternal(
const std::map<std::string,std::string> &nameMap) const
{
auto owner = Base::freecad_dynamic_cast<const DocumentObject>(getContainer());
if(!owner || !owner->getDocument() || !_pcLink || !_pcLink->getNameInDocument())
if(!owner || !owner->getDocument() || !_pcLink || !_pcLink->isAttachedToDocument())
return nullptr;
auto subs = updateLinkSubs(_pcLink,_SubList,
@@ -3440,7 +3440,7 @@ Property *PropertyXLink::CopyOnLabelChange(App::DocumentObject *obj,
const std::string &ref, const char *newLabel) const
{
auto owner = dynamic_cast<const DocumentObject*>(getContainer());
if(!owner || !owner->getDocument() || !_pcLink || !_pcLink->getNameInDocument())
if(!owner || !owner->getDocument() || !_pcLink || !_pcLink->isAttachedToDocument())
return nullptr;
auto subs = updateLinkSubs(_pcLink,_SubList,&updateLabelReference,obj,ref,newLabel);
if(subs.empty())
@@ -3455,7 +3455,7 @@ void PropertyXLink::copyTo(PropertyXLink &other,
{
if(!linked)
linked = _pcLink;
if(linked && linked->getNameInDocument()) {
if(linked && linked->isAttachedToDocument()) {
other.docName = linked->getDocument()->getName();
other.objectName = linked->getNameInDocument();
other.docInfo.reset();
@@ -3524,7 +3524,7 @@ bool PropertyXLink::hasXLink(
std::set<App::Document*> docs;
bool ret = false;
for(auto o : objs) {
if(o && o->getNameInDocument() && docs.insert(o->getDocument()).second) {
if(o && o->isAttachedToDocument() && docs.insert(o->getDocument()).second) {
if(!hasXLink(o->getDocument()))
continue;
if(!unsaved)
@@ -3553,7 +3553,7 @@ PropertyXLink::getDocumentOutList(App::Document *doc) {
|| link->testStatus(Property::PropNoPersist))
continue;
auto obj = dynamic_cast<App::DocumentObject*>(link->getContainer());
if(!obj || !obj->getNameInDocument() || !obj->getDocument())
if(!obj || !obj->isAttachedToDocument() || !obj->getDocument())
continue;
if(doc && obj->getDocument()!=doc)
continue;
@@ -3577,7 +3577,7 @@ PropertyXLink::getDocumentInList(App::Document *doc) {
|| link->testStatus(Property::PropNoPersist))
continue;
auto obj = dynamic_cast<App::DocumentObject*>(link->getContainer());
if(obj && obj->getNameInDocument() && obj->getDocument())
if(obj && obj->isAttachedToDocument() && obj->getDocument())
docs.insert(obj->getDocument());
}
}
@@ -3658,7 +3658,7 @@ const char *PropertyXLink::getSubName(bool newStyle) const {
void PropertyXLink::getLinks(std::vector<App::DocumentObject *> &objs,
bool all, std::vector<std::string> *subs, bool newStyle) const
{
if((all||_pcScope!=LinkScope::Hidden) && _pcLink && _pcLink->getNameInDocument()) {
if((all||_pcScope!=LinkScope::Hidden) && _pcLink && _pcLink->isAttachedToDocument()) {
objs.push_back(_pcLink);
if(subs && _SubList.size()==_ShadowSubList.size())
*subs = getSubValues(newStyle);
@@ -3668,7 +3668,7 @@ void PropertyXLink::getLinks(std::vector<App::DocumentObject *> &objs,
bool PropertyXLink::adjustLink(const std::set<App::DocumentObject*> &inList) {
if (_pcScope==LinkScope::Hidden)
return false;
if(!_pcLink || !_pcLink->getNameInDocument() || !inList.count(_pcLink))
if(!_pcLink || !_pcLink->isAttachedToDocument() || !inList.count(_pcLink))
return false;
auto subs = _SubList;
auto link = adjustLinkSubs(this,inList,_pcLink,subs);
@@ -3854,7 +3854,7 @@ void PropertyXLinkSubList::setValues(
std::map<App::DocumentObject*,std::vector<std::string> > &&values)
{
for(auto &v : values) {
if(!v.first || !v.first->getNameInDocument())
if(!v.first || !v.first->isAttachedToDocument())
FC_THROWM(Base::ValueError,"invalid document object");
}
@@ -3887,7 +3887,7 @@ void PropertyXLinkSubList::addValue(App::DocumentObject *obj,
void PropertyXLinkSubList::addValue(App::DocumentObject *obj,
std::vector<std::string> &&subs, bool reset) {
if(!obj || !obj->getNameInDocument())
if(!obj || !obj->isAttachedToDocument())
FC_THROWM(Base::ValueError,"invalid document object");
for(auto &l : _Links) {
@@ -3960,7 +3960,7 @@ const string PropertyXLinkSubList::getPyReprString() const
ss << '[';
for(auto &link : _Links) {
auto obj = link.getValue();
if(!obj || !obj->getNameInDocument())
if(!obj || !obj->isAttachedToDocument())
continue;
ss << "(App.getDocument('" << obj->getDocument()->getName()
<< "').getObject('" << obj->getNameInDocument() << "'), (";
@@ -4006,7 +4006,7 @@ PyObject *PropertyXLinkSubList::getPyObject()
Py::List list;
for(auto &link : _Links) {
auto obj = link.getValue();
if(!obj || !obj->getNameInDocument())
if(!obj || !obj->isAttachedToDocument())
continue;
Py::Tuple tup(2);
@@ -4279,7 +4279,7 @@ void PropertyXLinkSubList::getLinks(std::vector<App::DocumentObject *> &objs,
objs.reserve(objs.size()+_Links.size());
for(auto &l : _Links) {
auto obj = l.getValue();
if(obj && obj->getNameInDocument())
if(obj && obj->isAttachedToDocument())
objs.push_back(obj);
}
return;
@@ -4287,14 +4287,14 @@ void PropertyXLinkSubList::getLinks(std::vector<App::DocumentObject *> &objs,
size_t count=0;
for(auto &l : _Links) {
auto obj = l.getValue();
if(obj && obj->getNameInDocument())
if(obj && obj->isAttachedToDocument())
count += std::max((int)l.getSubValues().size(), 1);
}
if(!count) {
objs.reserve(objs.size()+_Links.size());
for(auto &l : _Links) {
auto obj = l.getValue();
if(obj && obj->getNameInDocument())
if(obj && obj->isAttachedToDocument())
objs.push_back(obj);
}
return;
@@ -4304,7 +4304,7 @@ void PropertyXLinkSubList::getLinks(std::vector<App::DocumentObject *> &objs,
subs->reserve(subs->size()+count);
for(auto &l : _Links) {
auto obj = l.getValue();
if(obj && obj->getNameInDocument()) {
if(obj && obj->isAttachedToDocument()) {
auto subnames = l.getSubValues(newStyle);
if (subnames.empty())
subnames.emplace_back("");
@@ -4340,7 +4340,7 @@ bool PropertyXLinkSubList::adjustLink(const std::set<App::DocumentObject*> &inLi
int count=0;
for(auto &l : _Links) {
auto obj = l.getValue();
if(!obj || !obj->getNameInDocument()) {
if(!obj || !obj->isAttachedToDocument()) {
++count;
continue;
}
@@ -4451,7 +4451,7 @@ PyObject *PropertyXLinkList::getPyObject()
{
for(auto &link : _Links) {
auto obj = link.getValue();
if(!obj || !obj->getNameInDocument())
if(!obj || !obj->isAttachedToDocument())
continue;
if(link.hasSubName())
return PropertyXLinkSubList::getPyObject();
@@ -4460,7 +4460,7 @@ PyObject *PropertyXLinkList::getPyObject()
Py::List list;
for(auto &link : _Links) {
auto obj = link.getValue();
if(!obj || !obj->getNameInDocument())
if(!obj || !obj->isAttachedToDocument())
continue;
list.append(Py::asObject(obj->getPyObject()));
}
@@ -4515,10 +4515,10 @@ void PropertyXLinkContainer::afterRestore() {
}
void PropertyXLinkContainer::breakLink(App::DocumentObject *obj, bool clear) {
if(!obj || !obj->getNameInDocument())
if(!obj || !obj->isAttachedToDocument())
return;
auto owner = dynamic_cast<App::DocumentObject*>(getContainer());
if(!owner || !owner->getNameInDocument())
if(!owner || !owner->isAttachedToDocument())
return;
if(!clear || obj!=owner) {
auto it = _Deps.find(obj);
@@ -4538,7 +4538,7 @@ void PropertyXLinkContainer::breakLink(App::DocumentObject *obj, bool clear) {
return;
for(auto &v : _Deps) {
auto key = v.first;
if(!key || !key->getNameInDocument())
if(!key || !key->isAttachedToDocument())
continue;
onBreakLink(key);
if(!v.second && key->getDocument()==owner->getDocument())
@@ -4678,13 +4678,13 @@ bool PropertyXLinkContainer::isLinkedToDocument(const App::Document &doc) const
void PropertyXLinkContainer::updateDeps(std::map<DocumentObject*,bool> &&newDeps) {
auto owner = Base::freecad_dynamic_cast<App::DocumentObject>(getContainer());
if(!owner || !owner->getNameInDocument())
if(!owner || !owner->isAttachedToDocument())
return;
newDeps.erase(owner);
for(auto &v : newDeps) {
auto obj = v.first;
if(obj && obj->getNameInDocument()) {
if(obj && obj->isAttachedToDocument()) {
auto it = _Deps.find(obj);
if(it != _Deps.end()) {
if(v.second != it->second) {
@@ -4712,7 +4712,7 @@ void PropertyXLinkContainer::updateDeps(std::map<DocumentObject*,bool> &&newDeps
}
for(auto &v : _Deps) {
auto obj = v.first;
if(!obj || !obj->getNameInDocument())
if(!obj || !obj->isAttachedToDocument())
continue;
if(obj->getDocument()==owner->getDocument()) {
if(!v.second)
@@ -4736,13 +4736,13 @@ void PropertyXLinkContainer::updateDeps(std::map<DocumentObject*,bool> &&newDeps
void PropertyXLinkContainer::clearDeps() {
auto owner = dynamic_cast<App::DocumentObject*>(getContainer());
if(!owner || !owner->getNameInDocument())
if(!owner || !owner->isAttachedToDocument())
return;
#ifndef USE_OLD_DAG
if (!owner->testStatus(ObjectStatus::Destroy)) {
for(auto &v : _Deps) {
auto obj = v.first;
if(!v.second && obj && obj->getNameInDocument() && obj->getDocument()==owner->getDocument())
if(!v.second && obj && obj->isAttachedToDocument() && obj->getDocument()==owner->getDocument())
obj->_removeBackLink(owner);
}
}
+5 -4
View File
@@ -423,8 +423,9 @@ void PropertyEnumeration::Restore(Base::XMLReader &reader)
if (val < 0) {
// If the enum is empty at this stage do not print a warning
if (_enum.hasEnums())
Base::Console().Warning("Enumeration index %d is out of range, ignore it\n", val);
if (_enum.hasEnums()) {
Base::Console().DeveloperWarning(std::string("PropertyEnumeration"), "Enumeration index %d is out of range, ignore it\n", val);
}
val = getValue();
}
@@ -1315,7 +1316,7 @@ void PropertyString::setValue(const char* newLabel)
auto obj = dynamic_cast<DocumentObject*>(getContainer());
bool commit = false;
if(obj && obj->getNameInDocument() && this==&obj->Label &&
if(obj && obj->isAttachedToDocument() && this==&obj->Label &&
(!obj->getDocument()->testStatus(App::Document::Restoring)||
obj->getDocument()->testStatus(App::Document::Importing)) &&
!obj->getDocument()->isPerformingTransaction())
@@ -1456,7 +1457,7 @@ void PropertyString::Save (Base::Writer &writer) const
auto obj = dynamic_cast<DocumentObject*>(getContainer());
writer.Stream() << writer.ind() << "<String ";
bool exported = false;
if(obj && obj->getNameInDocument() &&
if(obj && obj->isAttachedToDocument() &&
obj->isExporting() && &obj->Label==this)
{
if(obj->allowDuplicateLabel())
+10 -10
View File
@@ -151,15 +151,15 @@ public:
/// @name Flag accessors
//@{
bool isBinary() const;
bool isHashed() const;
bool isPostfixed() const;
bool isPostfixEncoded() const;
bool isIndexed() const;
bool isPrefixID() const;
bool isPrefixIDIndex() const;
bool isMarked() const;
bool isPersistent() const;
inline bool isBinary() const;
inline bool isHashed() const;
inline bool isPostfixed() const;
inline bool isPostfixEncoded() const;
inline bool isIndexed() const;
inline bool isPrefixID() const;
inline bool isPrefixIDIndex() const;
inline bool isMarked() const;
inline bool isPersistent() const;
//@}
/// Checks if this StringID is from the input hasher
@@ -278,7 +278,7 @@ public:
void mark() const;
/// Mark the StringID as persistent regardless of usage mark
void setPersistent(bool enable);
inline void setPersistent(bool enable);
bool operator<(const StringID& other) const
{
+10 -10
View File
@@ -38,9 +38,9 @@ void Axis::reverse()
Axis Axis::reversed() const
{
Axis a(*this);
a.reverse();
return a;
Axis axis(*this);
axis.reverse();
return axis;
}
void Axis::move(const Vector3d& MovVec)
@@ -58,16 +58,16 @@ bool Axis::operator!=(const Axis& that) const
return !(*this == that);
}
Axis& Axis::operator*=(const Placement& p)
Axis& Axis::operator*=(const Placement& plm)
{
p.multVec(this->_base, this->_base);
p.getRotation().multVec(this->_dir, this->_dir);
plm.multVec(this->_base, this->_base);
plm.getRotation().multVec(this->_dir, this->_dir);
return *this;
}
Axis Axis::operator*(const Placement& p) const
Axis Axis::operator*(const Placement& plm) const
{
Axis a(*this);
a *= p;
return a;
Axis axis(*this);
axis *= plm;
return axis;
}
+2 -2
View File
@@ -67,8 +67,8 @@ public:
/** Operators. */
//@{
Axis& operator*=(const Placement& p);
Axis operator*(const Placement& p) const;
Axis& operator*=(const Placement& plm);
Axis operator*(const Placement& plm) const;
bool operator==(const Axis&) const;
bool operator!=(const Axis&) const;
Axis& operator=(const Axis&) = default;
+1 -1
View File
@@ -47,7 +47,7 @@ std::string AxisPy::representation() const
return str.str();
}
PyObject* AxisPy::PyMake(struct _typeobject*, PyObject*, PyObject*) // Python wrapper
PyObject* AxisPy::PyMake(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/)
{
// create a new instance of AxisPy and the Twin object
return new AxisPy(new Axis);
+2 -5
View File
@@ -106,11 +106,8 @@ void BaseClass::initSubclass(Base::Type& toInit,
*/
PyObject* BaseClass::getPyObject()
{
assert(0);
Py_Return;
}
void BaseClass::setPyObject(PyObject*)
{
assert(0);
}
void BaseClass::setPyObject(PyObject* /*unused*/)
{}
+12 -12
View File
@@ -30,6 +30,7 @@
using PyObject = struct _object;
// NOLINTBEGIN(cppcoreguidelines-macro-usage)
/// define for subclassing Base::BaseClass
#define TYPESYSTEM_HEADER() \
public: \
@@ -129,6 +130,7 @@ private:
{ \
initSubclass(_class_::classTypeId, #_class_, #_parentclass_, &(_class_::create)); \
}
// NOLINTEND(cppcoreguidelines-macro-usage)
namespace Base
{
@@ -191,14 +193,13 @@ public:
*
*/
template<typename T>
T* freecad_dynamic_cast(Base::BaseClass* t)
T* freecad_dynamic_cast(Base::BaseClass* type)
{
if (t && t->isDerivedFrom(T::getClassTypeId())) {
return static_cast<T*>(t);
}
else {
return nullptr;
if (type && type->isDerivedFrom(T::getClassTypeId())) {
return static_cast<T*>(type);
}
return nullptr;
}
/**
@@ -207,14 +208,13 @@ T* freecad_dynamic_cast(Base::BaseClass* t)
*
*/
template<typename T>
const T* freecad_dynamic_cast(const Base::BaseClass* t)
const T* freecad_dynamic_cast(const Base::BaseClass* type)
{
if (t && t->isDerivedFrom(T::getClassTypeId())) {
return static_cast<const T*>(t);
}
else {
return nullptr;
if (type && type->isDerivedFrom(T::getClassTypeId())) {
return static_cast<const T*>(type);
}
return nullptr;
}
+2
View File
@@ -44,6 +44,7 @@
@endcode
*/
// NOLINTBEGIN
// clang-format off
// Based on https://stackoverflow.com/questions/1448396/how-to-use-enums-as-flags-in-c
template<class T = void> struct enum_traits {};
@@ -130,5 +131,6 @@ public:
};
}
// clang-format on
// NOLINTEND
#endif
+51 -35
View File
@@ -45,7 +45,7 @@ std::string BoundBoxPy::representation() const
return str.str();
}
PyObject* BoundBoxPy::PyMake(struct _typeobject*, PyObject*, PyObject*) // Python wrapper
PyObject* BoundBoxPy::PyMake(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/)
{
// create a new instance of BoundBoxPy and the Twin object
return new BoundBoxPy(new BoundBox3d);
@@ -59,8 +59,14 @@ int BoundBoxPy::PyInit(PyObject* args, PyObject* /*kwd*/)
}
PyErr_Clear(); // set by PyArg_ParseTuple()
double xMin = 0.0, yMin = 0.0, zMin = 0.0, xMax = 0.0, yMax = 0.0, zMax = 0.0;
PyObject *object1 {}, *object2 {};
double xMin = 0.0;
double yMin = 0.0;
double zMin = 0.0;
double xMax = 0.0;
double yMax = 0.0;
double zMax = 0.0;
PyObject* object1 {};
PyObject* object2 {};
BoundBoxPy::PointerType ptr = getBoundBoxPtr();
if (PyArg_ParseTuple(args, "d|ddddd", &xMin, &yMin, &zMin, &xMax, &yMax, &zMax)) {
ptr->MaxX = xMax;
@@ -128,7 +134,9 @@ PyObject* BoundBoxPy::isValid(PyObject* args)
PyObject* BoundBoxPy::add(PyObject* args)
{
double x {}, y {}, z {};
double x {};
double y {};
double z {};
PyObject* object {};
if (PyArg_ParseTuple(args, "ddd", &x, &y, &z)) {
getBoundBoxPtr()->Add(Vector3d(x, y, z));
@@ -189,7 +197,8 @@ PyObject* BoundBoxPy::getEdge(PyObject* args)
return nullptr;
}
Base::Vector3d pnt1, pnt2;
Base::Vector3d pnt1;
Base::Vector3d pnt2;
getBoundBoxPtr()->CalcEdge(index, pnt1, pnt2);
Py::Tuple tuple(2);
tuple.setItem(0, Py::Vector(pnt1));
@@ -199,7 +208,9 @@ PyObject* BoundBoxPy::getEdge(PyObject* args)
PyObject* BoundBoxPy::closestPoint(PyObject* args)
{
double x {}, y {}, z {};
double x {};
double y {};
double z {};
PyObject* object {};
Base::Vector3d vec;
@@ -221,10 +232,9 @@ PyObject* BoundBoxPy::closestPoint(PyObject* args)
vec = *(static_cast<Base::VectorPy*>(object)->getVectorPtr());
break;
}
else {
PyErr_SetString(PyExc_TypeError, "Either three floats or vector expected");
return nullptr;
}
PyErr_SetString(PyExc_TypeError, "Either three floats or vector expected");
return nullptr;
} while (false);
Base::Vector3d point = getBoundBoxPtr()->ClosestPoint(vec);
@@ -233,7 +243,8 @@ PyObject* BoundBoxPy::closestPoint(PyObject* args)
PyObject* BoundBoxPy::intersect(PyObject* args)
{
PyObject *object {}, *object2 {};
PyObject* object1 {};
PyObject* object2 {};
Py::Boolean retVal;
if (!getBoundBoxPtr()->IsValid()) {
@@ -245,23 +256,23 @@ PyObject* BoundBoxPy::intersect(PyObject* args)
if (PyArg_ParseTuple(args,
"O!O!",
&(Base::VectorPy::Type),
&object,
&object1,
&(Base::VectorPy::Type),
&object2)) {
retVal = getBoundBoxPtr()->IsCutLine(
*(static_cast<Base::VectorPy*>(object)->getVectorPtr()),
*(static_cast<Base::VectorPy*>(object1)->getVectorPtr()),
*(static_cast<Base::VectorPy*>(object2)->getVectorPtr()));
break;
}
PyErr_Clear();
if (PyArg_ParseTuple(args, "O!", &(Base::BoundBoxPy::Type), &object)) {
if (!static_cast<Base::BoundBoxPy*>(object)->getBoundBoxPtr()->IsValid()) {
if (PyArg_ParseTuple(args, "O!", &(Base::BoundBoxPy::Type), &object1)) {
if (!static_cast<Base::BoundBoxPy*>(object1)->getBoundBoxPtr()->IsValid()) {
PyErr_SetString(PyExc_FloatingPointError, "Invalid bounding box argument");
return nullptr;
}
retVal = getBoundBoxPtr()->Intersect(
*(static_cast<Base::BoundBoxPy*>(object)->getBoundBoxPtr()));
*(static_cast<Base::BoundBoxPy*>(object1)->getBoundBoxPtr()));
break;
}
@@ -326,12 +337,13 @@ PyObject* BoundBoxPy::enlarge(PyObject* args)
PyObject* BoundBoxPy::getIntersectionPoint(PyObject* args)
{
PyObject *object {}, *object2 {};
PyObject* object1 {};
PyObject* object2 {};
double epsilon = 0.0001;
if (!PyArg_ParseTuple(args,
"O!O!|d;Need base and direction vector",
&(Base::VectorPy::Type),
&object,
&object1,
&(Base::VectorPy::Type),
&object2,
&epsilon)) {
@@ -340,22 +352,23 @@ PyObject* BoundBoxPy::getIntersectionPoint(PyObject* args)
Base::Vector3d point;
bool ok = getBoundBoxPtr()->IntersectionPoint(
*(static_cast<Base::VectorPy*>(object)->getVectorPtr()),
*(static_cast<Base::VectorPy*>(object1)->getVectorPtr()),
*(static_cast<Base::VectorPy*>(object2)->getVectorPtr()),
point,
epsilon);
if (ok) {
return new VectorPy(point);
}
else {
PyErr_SetString(Base::PyExc_FC_GeneralError, "No intersection");
return nullptr;
}
PyErr_SetString(Base::PyExc_FC_GeneralError, "No intersection");
return nullptr;
}
PyObject* BoundBoxPy::move(PyObject* args)
{
double x {}, y {}, z {};
double x {};
double y {};
double z {};
PyObject* object {};
Base::Vector3d vec;
@@ -377,10 +390,9 @@ PyObject* BoundBoxPy::move(PyObject* args)
vec = *(static_cast<Base::VectorPy*>(object)->getVectorPtr());
break;
}
else {
PyErr_SetString(PyExc_TypeError, "Either three floats or vector expected");
return nullptr;
}
PyErr_SetString(PyExc_TypeError, "Either three floats or vector expected");
return nullptr;
} while (false);
getBoundBoxPtr()->MoveX(vec.x);
@@ -392,7 +404,9 @@ PyObject* BoundBoxPy::move(PyObject* args)
PyObject* BoundBoxPy::scale(PyObject* args)
{
double x {}, y {}, z {};
double x {};
double y {};
double z {};
PyObject* object {};
Base::Vector3d vec;
@@ -414,10 +428,9 @@ PyObject* BoundBoxPy::scale(PyObject* args)
vec = *(static_cast<Base::VectorPy*>(object)->getVectorPtr());
break;
}
else {
PyErr_SetString(PyExc_TypeError, "Either three floats or vector expected");
return nullptr;
}
PyErr_SetString(PyExc_TypeError, "Either three floats or vector expected");
return nullptr;
} while (false);
getBoundBoxPtr()->ScaleX(vec.x);
@@ -445,7 +458,8 @@ PyObject* BoundBoxPy::transformed(PyObject* args)
PyObject* BoundBoxPy::isCutPlane(PyObject* args)
{
PyObject *object {}, *object2 {};
PyObject* object {};
PyObject* object2 {};
Py::Boolean retVal;
if (!getBoundBoxPtr()->IsValid()) {
@@ -470,7 +484,9 @@ PyObject* BoundBoxPy::isCutPlane(PyObject* args)
PyObject* BoundBoxPy::isInside(PyObject* args)
{
double x {}, y {}, z {};
double x {};
double y {};
double z {};
PyObject* object {};
Py::Boolean retVal;
+33 -38
View File
@@ -313,8 +313,8 @@ void InventorFieldWriter::write<int>(const char* fieldName,
// -----------------------------------------------------------------------------
LabelItem::LabelItem(const std::string& text)
: text(text)
LabelItem::LabelItem(std::string text)
: text(std::move(text))
{}
void LabelItem::write(InventorOutput& out) const
@@ -326,8 +326,8 @@ void LabelItem::write(InventorOutput& out) const
// -----------------------------------------------------------------------------
InfoItem::InfoItem(const std::string& text)
: text(text)
InfoItem::InfoItem(std::string text)
: text(std::move(text))
{}
void InfoItem::write(InventorOutput& out) const
@@ -403,10 +403,8 @@ void LineItem::write(InventorOutput& out) const
// -----------------------------------------------------------------------------
MultiLineItem::MultiLineItem(const std::vector<Vector3f>& points,
DrawStyle drawStyle,
const ColorRGB& rgb)
: points {points}
MultiLineItem::MultiLineItem(std::vector<Vector3f> points, DrawStyle drawStyle, const ColorRGB& rgb)
: points {std::move(points)}
, drawStyle {drawStyle}
, rgb {rgb}
{}
@@ -456,9 +454,9 @@ void ArrowItem::write(InventorOutput& out) const
dir.Scale(sf2, sf2, sf2);
Vector3f cpt = line.p1 + dir;
Vector3f rot = Vector3f(0.0f, 1.0f, 0.0f) % dir;
Vector3f rot = Vector3f(0.0F, 1.0F, 0.0F) % dir;
rot.Normalize();
float angle = Vector3f(0.0f, 1.0f, 0.0f).GetAngle(dir);
float angle = Vector3f(0.0F, 1.0F, 0.0F).GetAngle(dir);
out.write() << "Separator {\n";
out.write() << " Material { diffuseColor " << rgb.red() << " " << rgb.green() << " "
@@ -670,7 +668,6 @@ void ShapeHintsItem::setShapeType(ShapeType::Type value)
shapeType.type = value;
}
void ShapeHintsItem::write(InventorOutput& out) const
{
out.write() << "ShapeHints {\n";
@@ -699,8 +696,8 @@ void PolygonOffsetItem::write(InventorOutput& out) const
// -----------------------------------------------------------------------------
Coordinate3Item::Coordinate3Item(const std::vector<Vector3f>& points)
: points(points)
Coordinate3Item::Coordinate3Item(std::vector<Vector3f> points)
: points(std::move(points))
{}
void Coordinate3Item::write(InventorOutput& out) const
@@ -739,8 +736,8 @@ void LineSetItem::write(InventorOutput& out) const
// -----------------------------------------------------------------------------
FaceSetItem::FaceSetItem(const std::vector<int>& indices)
: indices(indices)
FaceSetItem::FaceSetItem(std::vector<int> indices)
: indices(std::move(indices))
{}
void FaceSetItem::write(InventorOutput& out) const
@@ -755,8 +752,8 @@ void FaceSetItem::write(InventorOutput& out) const
// -----------------------------------------------------------------------------
IndexedLineSetItem::IndexedLineSetItem(const std::vector<int>& indices)
: indices(indices)
IndexedLineSetItem::IndexedLineSetItem(std::vector<int> indices)
: indices(std::move(indices))
{}
void IndexedLineSetItem::write(InventorOutput& out) const
@@ -771,8 +768,8 @@ void IndexedLineSetItem::write(InventorOutput& out) const
// -----------------------------------------------------------------------------
IndexedFaceSetItem::IndexedFaceSetItem(const std::vector<int>& indices)
: indices(indices)
IndexedFaceSetItem::IndexedFaceSetItem(std::vector<int> indices)
: indices(std::move(indices))
{}
void IndexedFaceSetItem::write(InventorOutput& out) const
@@ -787,8 +784,8 @@ void IndexedFaceSetItem::write(InventorOutput& out) const
// -----------------------------------------------------------------------------
NormalItem::NormalItem(const std::vector<Base::Vector3f>& vec)
: vector(vec)
NormalItem::NormalItem(std::vector<Base::Vector3f> vec)
: vector(std::move(vec))
{}
void NormalItem::write(InventorOutput& out) const
@@ -903,8 +900,8 @@ void NurbsSurfaceItem::write(InventorOutput& out) const
// -----------------------------------------------------------------------------
Text2Item::Text2Item(const std::string& string)
: string(string)
Text2Item::Text2Item(std::string string)
: string(std::move(string))
{}
void Text2Item::write(InventorOutput& out) const
@@ -915,6 +912,7 @@ void Text2Item::write(InventorOutput& out) const
// -----------------------------------------------------------------------------
// NOLINTNEXTLINE
TransformItem::TransformItem(const Base::Placement& placement)
: placement(placement)
{}
@@ -941,8 +939,8 @@ void TransformItem::write(InventorOutput& out) const
// -----------------------------------------------------------------------------
InventorBuilder::InventorBuilder(std::ostream& output)
: result(output)
InventorBuilder::InventorBuilder(std::ostream& str)
: result(str)
{
addHeader();
}
@@ -1020,7 +1018,7 @@ void Builder3D::saveToLog()
ILogger* obs = Base::Console().Get("StatusBar");
if (obs) {
obs->SendLog("Builder3D",
result.str().c_str(),
result.str(),
Base::LogStyle::Log,
Base::IntendedRecipient::Developer,
Base::ContentType::Untranslatable);
@@ -1073,7 +1071,7 @@ std::vector<T> InventorLoader::readData(const char* fieldName) const
bool found = false;
while (std::getline(inp, str)) {
std::string::size_type point = str.find(fieldName);
std::string::size_type open = str.find("[");
std::string::size_type open = str.find('[');
if (point != std::string::npos && open > point) {
str = str.substr(open);
found = true;
@@ -1101,7 +1099,7 @@ std::vector<T> InventorLoader::readData(const char* fieldName) const
}
// search for ']' to finish the reading
if (str.find("]") != std::string::npos) {
if (str.find(']') != std::string::npos) {
break;
}
} while (std::getline(inp, str));
@@ -1240,25 +1238,22 @@ bool InventorLoader::read()
bool InventorLoader::isValid() const
{
int32_t value {static_cast<int32_t>(points.size())};
auto inRange = [value](const Face& f) {
if (f.p1 < 0 || f.p1 >= value) {
auto inRange = [value](const Face& face) {
if (face.p1 < 0 || face.p1 >= value) {
return false;
}
if (f.p2 < 0 || f.p2 >= value) {
if (face.p2 < 0 || face.p2 >= value) {
return false;
}
if (f.p3 < 0 || f.p3 >= value) {
if (face.p3 < 0 || face.p3 >= value) {
return false;
}
return true;
};
for (auto it : faces) {
if (!inRange(it)) {
return false;
}
}
return true;
return std::all_of(faces.cbegin(), faces.cend(), [&inRange](const Face& face) {
return inRange(face);
});
}
namespace Base
+13 -16
View File
@@ -26,12 +26,9 @@
// Std. configurations
#ifdef __GNUC__
#include <cstdint>
#endif
#include <sstream>
#include <vector>
#include <cstdint>
#include <Base/Tools3D.h>
#ifndef FC_GLOBAL_H
#include <FCGlobal.h>
@@ -208,13 +205,13 @@ public:
{
spaces -= 2;
}
int count()
int count() const
{
return spaces;
}
friend std::ostream& operator<<(std::ostream& os, Indentation m)
friend std::ostream& operator<<(std::ostream& os, Indentation ind)
{
for (int i = 0; i < m.count(); i++) {
for (int i = 0; i < ind.count(); i++) {
os << " ";
}
return os;
@@ -260,7 +257,7 @@ protected:
class BaseExport LabelItem: public NodeItem
{
public:
explicit LabelItem(const std::string& text);
explicit LabelItem(std::string text);
void write(InventorOutput& out) const override;
private:
@@ -273,7 +270,7 @@ private:
class BaseExport InfoItem: public NodeItem
{
public:
explicit InfoItem(const std::string& text);
explicit InfoItem(std::string text);
void write(InventorOutput& out) const override;
private:
@@ -326,7 +323,7 @@ class BaseExport MultiLineItem: public NodeItem
public:
/// add a line defined by a list of points whereat always a pair (i.e. a point and the following
/// point) builds a line.
explicit MultiLineItem(const std::vector<Vector3f>& points,
explicit MultiLineItem(std::vector<Vector3f> points,
DrawStyle drawStyle,
const ColorRGB& rgb = ColorRGB {1.0F, 1.0F, 1.0F});
void write(InventorOutput& out) const override;
@@ -466,7 +463,7 @@ private:
class BaseExport Coordinate3Item: public NodeItem
{
public:
explicit Coordinate3Item(const std::vector<Vector3f>& points);
explicit Coordinate3Item(std::vector<Vector3f> points);
void write(InventorOutput& out) const override;
private:
@@ -499,7 +496,7 @@ public:
class BaseExport FaceSetItem: public NodeItem
{
public:
explicit FaceSetItem(const std::vector<int>&);
explicit FaceSetItem(std::vector<int>);
void write(InventorOutput& out) const override;
private:
@@ -512,7 +509,7 @@ private:
class BaseExport IndexedLineSetItem: public NodeItem
{
public:
explicit IndexedLineSetItem(const std::vector<int>&);
explicit IndexedLineSetItem(std::vector<int>);
void write(InventorOutput& out) const override;
private:
@@ -525,7 +522,7 @@ private:
class BaseExport IndexedFaceSetItem: public NodeItem
{
public:
explicit IndexedFaceSetItem(const std::vector<int>&);
explicit IndexedFaceSetItem(std::vector<int>);
void write(InventorOutput& out) const override;
private:
@@ -538,7 +535,7 @@ private:
class BaseExport NormalItem: public NodeItem
{
public:
explicit NormalItem(const std::vector<Base::Vector3f>& vec);
explicit NormalItem(std::vector<Base::Vector3f> vec);
void write(InventorOutput& out) const override;
private:
@@ -627,7 +624,7 @@ private:
class BaseExport Text2Item: public NodeItem
{
public:
explicit Text2Item(const std::string&);
explicit Text2Item(std::string);
void write(InventorOutput& out) const override;
private:
+23 -29
View File
@@ -68,7 +68,6 @@ public:
, notifier(notifier)
, msg(msg)
{}
~ConsoleEvent() override = default;
};
class ConsoleOutput: public QObject // clazy:exclude=missing-qobject-macro
@@ -139,13 +138,10 @@ public:
}
private:
ConsoleOutput() = default;
~ConsoleOutput() override = default;
static ConsoleOutput* instance;
static ConsoleOutput* instance; // NOLINT
};
ConsoleOutput* ConsoleOutput::instance = nullptr;
ConsoleOutput* ConsoleOutput::instance = nullptr; // NOLINT
} // namespace Base
@@ -176,9 +172,9 @@ ConsoleSingleton::~ConsoleSingleton()
/**
* sets the console in a special mode
*/
void ConsoleSingleton::SetConsoleMode(ConsoleMode m)
void ConsoleSingleton::SetConsoleMode(ConsoleMode mode)
{
if (m & Verbose) {
if (mode & Verbose) {
_bVerbose = true;
}
}
@@ -186,9 +182,9 @@ void ConsoleSingleton::SetConsoleMode(ConsoleMode m)
/**
* unsets the console from a special mode
*/
void ConsoleSingleton::UnsetConsoleMode(ConsoleMode m)
void ConsoleSingleton::UnsetConsoleMode(ConsoleMode mode)
{
if (m & Verbose) {
if (mode & Verbose) {
_bVerbose = false;
}
}
@@ -211,54 +207,53 @@ void ConsoleSingleton::UnsetConsoleMode(ConsoleMode m)
* switches off warnings and error messages and restore the state before the modification.
* If the observer \a sObs doesn't exist then nothing happens.
*/
ConsoleMsgFlags ConsoleSingleton::SetEnabledMsgType(const char* sObs, ConsoleMsgFlags type, bool b)
ConsoleMsgFlags ConsoleSingleton::SetEnabledMsgType(const char* sObs, ConsoleMsgFlags type, bool on)
{
ILogger* pObs = Get(sObs);
if (pObs) {
ConsoleMsgFlags flags = 0;
if (type & MsgType_Err) {
if (pObs->bErr != b) {
if (pObs->bErr != on) {
flags |= MsgType_Err;
}
pObs->bErr = b;
pObs->bErr = on;
}
if (type & MsgType_Wrn) {
if (pObs->bWrn != b) {
if (pObs->bWrn != on) {
flags |= MsgType_Wrn;
}
pObs->bWrn = b;
pObs->bWrn = on;
}
if (type & MsgType_Txt) {
if (pObs->bMsg != b) {
if (pObs->bMsg != on) {
flags |= MsgType_Txt;
}
pObs->bMsg = b;
pObs->bMsg = on;
}
if (type & MsgType_Log) {
if (pObs->bLog != b) {
if (pObs->bLog != on) {
flags |= MsgType_Log;
}
pObs->bLog = b;
pObs->bLog = on;
}
if (type & MsgType_Critical) {
if (pObs->bCritical != b) {
if (pObs->bCritical != on) {
flags |= MsgType_Critical;
}
pObs->bCritical = b;
pObs->bCritical = on;
}
if (type & MsgType_Notification) {
if (pObs->bNotification != b) {
if (pObs->bNotification != on) {
flags |= MsgType_Notification;
}
pObs->bNotification = b;
pObs->bNotification = on;
}
return flags;
}
else {
return 0;
}
return 0;
}
bool ConsoleSingleton::IsMsgTypeEnabled(const char* sObs, FreeCAD_ConsoleMsgType type) const
@@ -814,9 +809,8 @@ PyObject* ConsoleSingleton::sPySetStatus(PyObject* /*self*/, PyObject* args)
Py_Return;
}
else {
Py_Error(Base::PyExc_FC_GeneralError, "Unknown logger type");
}
Py_Error(Base::PyExc_FC_GeneralError, "Unknown logger type");
}
PY_CATCH;
}
+35 -18
View File
@@ -341,6 +341,7 @@ using PyMethodDef = struct PyMethodDef;
*
*/
// NOLINTBEGIN(bugprone-reserved-identifier,bugprone-macro-parentheses,cppcoreguidelines-macro-usage)
#define FC_LOGLEVEL_DEFAULT -1
#define FC_LOGLEVEL_ERR 0
#define FC_LOGLEVEL_WARN 1
@@ -479,6 +480,7 @@ using PyMethodDef = struct PyMethodDef;
} while (0)
#endif // FC_LOG_NO_TIMING
// NOLINTEND(bugprone-reserved-identifier,bugprone-macro-parentheses,cppcoreguidelines-macro-usage)
// TODO: Get rid of this typedef
using ConsoleMsgFlags = unsigned int;
@@ -487,12 +489,12 @@ namespace Base
{
#ifndef FC_LOG_NO_TIMING
inline FC_DURATION GetDuration(FC_TIME_POINT& t)
inline FC_DURATION GetDuration(FC_TIME_POINT& tp)
{
auto tnow = std::chrono::FC_TIME_CLOCK::now();
auto d = std::chrono::duration_cast<FC_DURATION>(tnow - t);
t = tnow;
return d;
auto dc = std::chrono::duration_cast<FC_DURATION>(tnow - tp);
tp = tnow;
return dc;
}
#endif
@@ -548,6 +550,10 @@ class BaseExport ILogger
{
public:
ILogger() = default;
ILogger(const ILogger&) = delete;
ILogger(ILogger&&) = delete;
ILogger& operator=(const ILogger&) = delete;
ILogger& operator=(ILogger&&) = delete;
virtual ~ILogger() = 0;
/** Used to send a Log message at the given level.
@@ -571,24 +577,24 @@ public:
/**
* Returns whether a LogStyle category is active or not
*/
bool isActive(Base::LogStyle category)
bool isActive(Base::LogStyle category) const
{
if (category == Base::LogStyle::Log) {
return bLog;
}
else if (category == Base::LogStyle::Warning) {
if (category == Base::LogStyle::Warning) {
return bWrn;
}
else if (category == Base::LogStyle::Error) {
if (category == Base::LogStyle::Error) {
return bErr;
}
else if (category == Base::LogStyle::Message) {
if (category == Base::LogStyle::Message) {
return bMsg;
}
else if (category == Base::LogStyle::Critical) {
if (category == Base::LogStyle::Critical) {
return bCritical;
}
else if (category == Base::LogStyle::Notification) {
if (category == Base::LogStyle::Notification) {
return bNotification;
}
@@ -805,11 +811,11 @@ public:
};
/// Change mode
void SetConsoleMode(ConsoleMode m);
void SetConsoleMode(ConsoleMode mode);
/// Change mode
void UnsetConsoleMode(ConsoleMode m);
void UnsetConsoleMode(ConsoleMode mode);
/// Enables or disables message types of a certain console observer
ConsoleMsgFlags SetEnabledMsgType(const char* sObs, ConsoleMsgFlags type, bool b);
ConsoleMsgFlags SetEnabledMsgType(const char* sObs, ConsoleMsgFlags type, bool on);
/// Checks if message types of a certain console observer are enabled
bool IsMsgTypeEnabled(const char* sObs, FreeCAD_ConsoleMsgType type) const;
void SetConnectionMode(ConnectionMode mode);
@@ -839,7 +845,7 @@ public:
inline constexpr FreeCAD_ConsoleMsgType getConsoleMsg(Base::LogStyle style);
protected:
private:
// python exports goes here +++++++++++++++++++++++++++++++++++++++++++
// static python wrapper of the exported functions
static PyObject* sPyLog(PyObject* self, PyObject* args);
@@ -865,7 +871,13 @@ protected:
// Singleton!
ConsoleSingleton();
virtual ~ConsoleSingleton();
~ConsoleSingleton();
public:
ConsoleSingleton(const ConsoleSingleton&) = delete;
ConsoleSingleton(ConsoleSingleton&&) = delete;
ConsoleSingleton& operator=(const ConsoleSingleton&) = delete;
ConsoleSingleton& operator=(ConsoleSingleton&&) = delete;
private:
void postEvent(ConsoleSingleton::FreeCAD_ConsoleMsgType type,
@@ -881,7 +893,7 @@ private:
// singleton
static void Destruct();
static ConsoleSingleton* _pcSingleton;
static ConsoleSingleton* _pcSingleton; // NOLINT
// observer list
std::set<ILogger*> _aclObservers;
@@ -927,6 +939,11 @@ public:
{
Console().EnableRefresh(true);
}
ConsoleRefreshDisabler(const ConsoleRefreshDisabler&) = delete;
ConsoleRefreshDisabler(ConsoleRefreshDisabler&&) = delete;
ConsoleRefreshDisabler& operator=(const ConsoleRefreshDisabler&) = delete;
ConsoleRefreshDisabler& operator=(ConsoleRefreshDisabler&&) = delete;
};
@@ -957,9 +974,9 @@ public:
, refresh(refresh)
{}
bool isEnabled(int l)
bool isEnabled(int lev) const
{
return l <= level();
return lev <= level();
}
int level() const
+16 -16
View File
@@ -197,7 +197,7 @@ void ConsoleObserverStd::Error(const char* sErr)
}
}
void ConsoleObserverStd::Log(const char* sErr)
void ConsoleObserverStd::Log(const char* sLog)
{
if (useColorStderr) {
#if defined(FC_OS_WIN32)
@@ -208,7 +208,7 @@ void ConsoleObserverStd::Log(const char* sErr)
#endif
}
fprintf(stderr, "%s", sErr);
fprintf(stderr, "%s", sLog);
if (useColorStderr) {
#if defined(FC_OS_WIN32)
@@ -248,12 +248,12 @@ RedirectStdOutput::RedirectStdOutput()
buffer.reserve(80);
}
int RedirectStdOutput::overflow(int c)
int RedirectStdOutput::overflow(int ch)
{
if (c != EOF) {
buffer.push_back(static_cast<char>(c));
if (ch != EOF) {
buffer.push_back(static_cast<char>(ch));
}
return c;
return ch;
}
int RedirectStdOutput::sync()
@@ -271,12 +271,12 @@ RedirectStdLog::RedirectStdLog()
buffer.reserve(80);
}
int RedirectStdLog::overflow(int c)
int RedirectStdLog::overflow(int ch)
{
if (c != EOF) {
buffer.push_back(static_cast<char>(c));
if (ch != EOF) {
buffer.push_back(static_cast<char>(ch));
}
return c;
return ch;
}
int RedirectStdLog::sync()
@@ -294,12 +294,12 @@ RedirectStdError::RedirectStdError()
buffer.reserve(80);
}
int RedirectStdError::overflow(int c)
int RedirectStdError::overflow(int ch)
{
if (c != EOF) {
buffer.push_back(static_cast<char>(c));
if (ch != EOF) {
buffer.push_back(static_cast<char>(ch));
}
return c;
return ch;
}
int RedirectStdError::sync()
@@ -323,8 +323,8 @@ std::stringstream& LogLevel::prefix(std::stringstream& str, const char* src, int
_FC_TIME_INIT(s_tstart);
}
auto tnow = std::chrono::FC_TIME_CLOCK::now();
auto d = std::chrono::duration_cast<FC_DURATION>(tnow - s_tstart);
str << d.count() << ' ';
auto dc = std::chrono::duration_cast<FC_DURATION>(tnow - s_tstart);
str << dc.count() << ' ';
}
if (print_tag) {
str << '<' << tag << "> ";
+13 -8
View File
@@ -132,14 +132,19 @@ ILoggerBlocker::ILoggerBlocker(const char* co, ConsoleMsgFlags msgTypes)
ILoggerBlocker::~ILoggerBlocker()
{
try {
#ifdef FC_DEBUG
auto debug = Console().SetEnabledMsgType(conObs, msgTypesBlocked, true);
if (debug != msgTypesBlocked) {
Console().Warning("Enabled message types have been changed while ILoggerBlocker was set\n");
}
auto debug = Console().SetEnabledMsgType(conObs, msgTypesBlocked, true);
if (debug != msgTypesBlocked) {
Console().Warning(
"Enabled message types have been changed while ILoggerBlocker was set\n");
}
#else
Console().SetEnabledMsgType(conObs, msgTypesBlocked, true);
Console().SetEnabledMsgType(conObs, msgTypesBlocked, true);
#endif
}
catch (...) {
}
}
class BaseExport RedirectStdOutput: public std::streambuf
@@ -148,7 +153,7 @@ public:
RedirectStdOutput();
protected:
int overflow(int c = EOF) override;
int overflow(int ch = EOF) override;
int sync() override;
private:
@@ -161,7 +166,7 @@ public:
RedirectStdError();
protected:
int overflow(int c = EOF) override;
int overflow(int ch = EOF) override;
int sync() override;
private:
@@ -174,7 +179,7 @@ public:
RedirectStdLog();
protected:
int overflow(int c = EOF) override;
int overflow(int ch = EOF) override;
int sync() override;
private:
+29 -26
View File
@@ -42,8 +42,8 @@ struct vec_traits<Vector3f>
{
using vec_type = Vector3f;
using float_type = float;
vec_traits(const vec_type& v)
: v(v)
explicit vec_traits(const vec_type& vec)
: v(vec)
{}
inline std::tuple<float_type, float_type, float_type> get() const
{
@@ -59,8 +59,8 @@ struct vec_traits<Vector3d>
{
using vec_type = Vector3d;
using float_type = double;
vec_traits(const vec_type& v)
: v(v)
explicit vec_traits(const vec_type& vec)
: v(vec)
{}
inline std::tuple<float_type, float_type, float_type> get() const
{
@@ -76,12 +76,15 @@ struct vec_traits<Rotation>
{
using vec_type = Rotation;
using float_type = double;
vec_traits(const vec_type& v)
: v(v)
explicit vec_traits(const vec_type& vec)
: v(vec)
{}
inline std::tuple<float_type, float_type, float_type, float_type> get() const
{
float_type q1 {}, q2 {}, q3 {}, q4 {};
float_type q1 {};
float_type q2 {};
float_type q3 {};
float_type q4 {};
v.getValue(q1, q2, q3, q4);
return std::make_tuple(q1, q2, q3, q4);
}
@@ -91,36 +94,36 @@ private:
};
// type with three floats
template<class _Vec, typename float_type>
_Vec make_vec(const std::tuple<float_type, float_type, float_type>&& t)
template<class Vec, typename float_type>
Vec make_vec(const std::tuple<float_type, float_type, float_type>&& ft)
{
using traits_type = vec_traits<_Vec>;
using traits_type = vec_traits<Vec>;
using float_traits_type = typename traits_type::float_type;
return _Vec(float_traits_type(std::get<0>(t)),
float_traits_type(std::get<1>(t)),
float_traits_type(std::get<2>(t)));
return Vec(float_traits_type(std::get<0>(ft)),
float_traits_type(std::get<1>(ft)),
float_traits_type(std::get<2>(ft)));
}
// type with four floats
template<class _Vec, typename float_type>
_Vec make_vec(const std::tuple<float_type, float_type, float_type, float_type>&& t)
template<class Vec, typename float_type>
Vec make_vec(const std::tuple<float_type, float_type, float_type, float_type>&& ft)
{
using traits_type = vec_traits<_Vec>;
using traits_type = vec_traits<Vec>;
using float_traits_type = typename traits_type::float_type;
return _Vec(float_traits_type(std::get<0>(t)),
float_traits_type(std::get<1>(t)),
float_traits_type(std::get<2>(t)),
float_traits_type(std::get<3>(t)));
return Vec(float_traits_type(std::get<0>(ft)),
float_traits_type(std::get<1>(ft)),
float_traits_type(std::get<2>(ft)),
float_traits_type(std::get<3>(ft)));
}
template<class _Vec1, class _Vec2>
inline _Vec1 convertTo(const _Vec2& v)
template<class Vec1, class Vec2>
inline Vec1 convertTo(const Vec2& vec)
{
using traits_type = vec_traits<_Vec2>;
using traits_type = vec_traits<Vec2>;
using float_type = typename traits_type::float_type;
traits_type t(v);
auto tuple = t.get();
return make_vec<_Vec1, float_type>(std::move(tuple));
traits_type tt(vec);
auto tuple = tt.get();
return make_vec<Vec1, float_type>(std::move(tuple));
}
} // namespace Base
+24 -24
View File
@@ -36,23 +36,21 @@ CoordinateSystem::CoordinateSystem()
, ydir(0, 1, 0)
{}
CoordinateSystem::~CoordinateSystem() = default;
void CoordinateSystem::setAxes(const Axis& v, const Vector3d& xd)
void CoordinateSystem::setAxes(const Axis& vec, const Vector3d& xd)
{
if (xd.Sqr() < Base::Vector3d::epsilon()) {
throw Base::ValueError("Direction is null vector");
}
Vector3d yd = v.getDirection() % xd;
Vector3d yd = vec.getDirection() % xd;
if (yd.Sqr() < Base::Vector3d::epsilon()) {
throw Base::ValueError("Direction is parallel to Z direction");
}
ydir = yd;
ydir.Normalize();
xdir = ydir % v.getDirection();
xdir = ydir % vec.getDirection();
xdir.Normalize();
axis.setBase(v.getBase());
Base::Vector3d zdir = v.getDirection();
axis.setBase(vec.getBase());
Base::Vector3d zdir = vec.getDirection();
zdir.Normalize();
axis.setDirection(zdir);
}
@@ -75,9 +73,9 @@ void CoordinateSystem::setAxes(const Vector3d& n, const Vector3d& xd)
axis.setDirection(zdir);
}
void CoordinateSystem::setAxis(const Axis& v)
void CoordinateSystem::setAxis(const Axis& axis)
{
setAxes(v, xdir);
setAxes(axis, xdir);
}
void CoordinateSystem::setXDirection(const Vector3d& dir)
@@ -111,6 +109,7 @@ void CoordinateSystem::setZDirection(const Vector3d& dir)
Placement CoordinateSystem::displacement(const CoordinateSystem& cs) const
{
// NOLINTBEGIN
const Base::Vector3d& a = axis.getBase();
const Base::Vector3d& zdir = axis.getDirection();
Base::Matrix4D At;
@@ -148,36 +147,37 @@ Placement CoordinateSystem::displacement(const CoordinateSystem& cs) const
Placement PB(B);
Placement C = PB * PAt;
return C;
// NOLINTEND
}
void CoordinateSystem::transformTo(Vector3d& p)
void CoordinateSystem::transformTo(Vector3d& pnt)
{
return p.TransformToCoordinateSystem(axis.getBase(), xdir, ydir);
return pnt.TransformToCoordinateSystem(axis.getBase(), xdir, ydir);
}
void CoordinateSystem::transform(const Placement& p)
void CoordinateSystem::transform(const Placement& plm)
{
axis *= p;
p.getRotation().multVec(this->xdir, this->xdir);
p.getRotation().multVec(this->ydir, this->ydir);
axis *= plm;
plm.getRotation().multVec(this->xdir, this->xdir);
plm.getRotation().multVec(this->ydir, this->ydir);
}
void CoordinateSystem::transform(const Rotation& r)
void CoordinateSystem::transform(const Rotation& rot)
{
Vector3d zdir = axis.getDirection();
r.multVec(zdir, zdir);
rot.multVec(zdir, zdir);
axis.setDirection(zdir);
r.multVec(this->xdir, this->xdir);
r.multVec(this->ydir, this->ydir);
rot.multVec(this->xdir, this->xdir);
rot.multVec(this->ydir, this->ydir);
}
void CoordinateSystem::setPlacement(const Placement& p)
void CoordinateSystem::setPlacement(const Placement& plm)
{
Vector3d zdir(0, 0, 1);
p.getRotation().multVec(zdir, zdir);
axis.setBase(p.getPosition());
plm.getRotation().multVec(zdir, zdir);
axis.setBase(plm.getPosition());
axis.setDirection(zdir);
p.getRotation().multVec(Vector3d(1, 0, 0), this->xdir);
p.getRotation().multVec(Vector3d(0, 1, 0), this->ydir);
plm.getRotation().multVec(Vector3d(1, 0, 0), this->xdir);
plm.getRotation().multVec(Vector3d(0, 1, 0), this->ydir);
}
+12 -12
View File
@@ -41,7 +41,7 @@ public:
CoordinateSystem();
CoordinateSystem(const CoordinateSystem&) = default;
CoordinateSystem(CoordinateSystem&&) = default;
~CoordinateSystem();
~CoordinateSystem() = default;
CoordinateSystem& operator=(const CoordinateSystem&) = default;
CoordinateSystem& operator=(CoordinateSystem&&) = default;
@@ -49,7 +49,7 @@ public:
/** Sets the main axis. X and Y dir are adjusted accordingly.
* The main axis \a v must not be parallel to the X axis
*/
void setAxis(const Axis& v);
void setAxis(const Axis& axis);
/** Sets the main axis. X and Y dir are adjusted accordingly.
* The main axis must not be parallel to \a xd
*/
@@ -85,9 +85,9 @@ public:
{
return axis.getDirection();
}
inline void setPosition(const Vector3d& p)
inline void setPosition(const Vector3d& pos)
{
axis.setBase(p);
axis.setBase(pos);
}
inline const Vector3d& getPosition() const
{
@@ -99,17 +99,17 @@ public:
*/
Placement displacement(const CoordinateSystem& cs) const;
/** Transform the point \a p to be in this coordinate system */
void transformTo(Vector3d& p);
/** Transform the point \a pnt to be in this coordinate system */
void transformTo(Vector3d& pnt);
/** Apply the placement \a p to the coordinate system. */
void transform(const Placement& p);
/** Apply the placement \a plm to the coordinate system. */
void transform(const Placement& plm);
/** Apply the rotation \a r to the coordinate system. */
void transform(const Rotation& r);
/** Apply the rotation \a rot to the coordinate system. */
void transform(const Rotation& rot);
/** Set the placement \a p to the coordinate system. */
void setPlacement(const Placement& p);
/** Set the placement \a plm to the coordinate system. */
void setPlacement(const Placement& plm);
private:
Axis axis;
+11 -9
View File
@@ -38,7 +38,8 @@ std::string CoordinateSystemPy::representation() const
return {"<CoordinateSystem object>"};
}
PyObject* CoordinateSystemPy::PyMake(struct _typeobject*, PyObject*, PyObject*) // Python wrapper
PyObject*
CoordinateSystemPy::PyMake(PyTypeObject* /*unused*/, PyObject* /*unused*/, PyObject* /*unused*/)
{
// create a new instance of CoordinateSystemPy and the Twin object
return new CoordinateSystemPy(new CoordinateSystem);
@@ -52,7 +53,8 @@ int CoordinateSystemPy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
PyObject* CoordinateSystemPy::setAxes(PyObject* args)
{
PyObject *axis {}, *xdir {};
PyObject* axis {};
PyObject* xdir {};
if (PyArg_ParseTuple(args, "O!O!", &(AxisPy::Type), &axis, &(VectorPy::Type), &xdir)) {
getCoordinateSystemPtr()->setAxes(*static_cast<AxisPy*>(axis)->getAxisPtr(),
*static_cast<VectorPy*>(xdir)->getVectorPtr());
@@ -76,20 +78,20 @@ PyObject* CoordinateSystemPy::displacement(PyObject* args)
if (!PyArg_ParseTuple(args, "O!", &(CoordinateSystemPy::Type), &cs)) {
return nullptr;
}
Placement p = getCoordinateSystemPtr()->displacement(
Placement plm = getCoordinateSystemPtr()->displacement(
*static_cast<CoordinateSystemPy*>(cs)->getCoordinateSystemPtr());
return new PlacementPy(new Placement(p));
return new PlacementPy(new Placement(plm));
}
PyObject* CoordinateSystemPy::transformTo(PyObject* args)
{
PyObject* vec {};
if (!PyArg_ParseTuple(args, "O!", &(VectorPy::Type), &vec)) {
PyObject* vecpy {};
if (!PyArg_ParseTuple(args, "O!", &(VectorPy::Type), &vecpy)) {
return nullptr;
}
Vector3d v = static_cast<VectorPy*>(vec)->value();
getCoordinateSystemPtr()->transformTo(v);
return new VectorPy(new Vector3d(v));
Vector3d vec = static_cast<VectorPy*>(vecpy)->value();
getCoordinateSystemPtr()->transformTo(vec);
return new VectorPy(new Vector3d(vec));
}
PyObject* CoordinateSystemPy::transform(PyObject* args)
+1 -1
View File
@@ -51,7 +51,7 @@ void Debugger::detach()
isAttached = false;
}
bool Debugger::eventFilter(QObject*, QEvent* event)
bool Debugger::eventFilter(QObject* /*watched*/, QEvent* event)
{
if (event->type() == QEvent::KeyPress) {
if (loop.isRunning()) {
+1 -1
View File
@@ -59,7 +59,7 @@ class BaseExport Debugger: public QObject
Q_OBJECT
public:
Debugger(QObject* parent = nullptr);
explicit Debugger(QObject* parent = nullptr);
~Debugger() override;
Debugger(const Debugger&) = delete;
+3 -1
View File
@@ -25,6 +25,7 @@
#include <cmath>
// NOLINTBEGIN(readability-identifier-length)
namespace Base
{
@@ -44,7 +45,7 @@ public:
public:
DualNumber() = default;
DualNumber(double re, double du = 0.0)
DualNumber(double re, double du = 0.0) // NOLINT
: re(re)
, du(du)
{}
@@ -107,6 +108,7 @@ inline DualNumber pow(DualNumber a, double pw)
return {std::pow(a.re, pw), pw * std::pow(a.re, pw - 1.0) * a.du};
}
} // namespace Base
// NOLINTEND(readability-identifier-length)
#endif
+2
View File
@@ -26,6 +26,7 @@
#include "DualQuaternion.h"
// NOLINTBEGIN(readability-identifier-length)
Base::DualQuat Base::operator+(Base::DualQuat a, Base::DualQuat b)
{
return {a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w};
@@ -131,3 +132,4 @@ Base::DualQuat Base::DualQuat::pow(double t, bool shorten) const
m * sin(theta / 2) + pitch / 2 * cos(theta / 2) * l
+ DualQuat(0, 0, 0, -pitch / 2 * sin(theta / 2))};
}
// NOLINTEND(readability-identifier-length)
+2 -1
View File
@@ -26,7 +26,7 @@
#include "DualNumber.h"
#include <FCGlobal.h>
// NOLINTBEGIN(readability-identifier-length)
namespace Base
{
@@ -146,5 +146,6 @@ BaseExport DualQuat operator*(DualNumber a, DualQuat b);
} // namespace Base
// NOLINTEND(readability-identifier-length)
#endif
+64 -88
View File
@@ -38,15 +38,16 @@ TYPESYSTEM_SOURCE(Base::Exception, Base::BaseClass)
Exception::Exception()
: _line(0)
: _sErrMsg("FreeCAD Exception")
, _line(0)
, _isTranslatable(false)
, _isReported(false)
{
_sErrMsg = "FreeCAD Exception";
}
{}
Exception::Exception(const Exception& inst) = default;
Exception::Exception(Exception&& inst) noexcept = default;
Exception::Exception(const char* sMessage)
: _sErrMsg(sMessage)
, _line(0)
@@ -54,8 +55,8 @@ Exception::Exception(const char* sMessage)
, _isReported(false)
{}
Exception::Exception(const std::string& sMessage)
: _sErrMsg(sMessage)
Exception::Exception(std::string sMessage)
: _sErrMsg(std::move(sMessage))
, _line(0)
, _isTranslatable(false)
, _isReported(false)
@@ -67,6 +68,17 @@ Exception& Exception::operator=(const Exception& inst)
_file = inst._file;
_line = inst._line;
_function = inst._function;
_isTranslatable = inst._isTranslatable;
return *this;
}
Exception& Exception::operator=(Exception&& inst) noexcept
{
_sErrMsg = std::move(inst._sErrMsg);
_file = std::move(inst._file);
_line = inst._line;
_function = std::move(inst._function);
_isTranslatable = inst._isTranslatable;
return *this;
}
@@ -86,12 +98,14 @@ void Exception::ReportException() const
msg = _sErrMsg.c_str();
}
#ifdef FC_DEBUG
if (_function.size()) {
if (!_function.empty()) {
_FC_ERR(_file.c_str(), _line, _function << " -- " << msg);
}
else
#endif
{
_FC_ERR(_file.c_str(), _line, msg);
}
_isReported = true;
}
}
@@ -184,9 +198,7 @@ PyObject* AbortException::getPyExceptionType() const
// ---------------------------------------------------------
XMLBaseException::XMLBaseException()
: Exception()
{}
XMLBaseException::XMLBaseException() = default;
XMLBaseException::XMLBaseException(const char* sMessage)
: Exception(sMessage)
@@ -270,9 +282,8 @@ FileException::FileException(const char* sMessage, const FileInfo& File)
FileException::FileException()
: Exception("Unknown file exception happened")
{
_sErrMsgAndFileName = _sErrMsg;
}
, _sErrMsgAndFileName(_sErrMsg)
{}
void FileException::setFileName(const char* sFileName)
{
@@ -289,14 +300,6 @@ std::string FileException::getFileName() const
return file.fileName();
}
FileException& FileException::operator=(const FileException& inst)
{
Exception::operator=(inst);
file = inst.file;
_sErrMsgAndFileName = inst._sErrMsgAndFileName;
return *this;
}
const char* FileException::what() const noexcept
{
return _sErrMsgAndFileName.c_str();
@@ -313,12 +316,14 @@ void FileException::ReportException() const
msg = _sErrMsgAndFileName.c_str();
}
#ifdef FC_DEBUG
if (_function.size()) {
if (!_function.empty()) {
_FC_ERR(_file.c_str(), _line, _function << " -- " << msg);
}
else
#endif
{
_FC_ERR(_file.c_str(), _line, msg);
}
_isReported = true;
}
}
@@ -350,9 +355,7 @@ PyObject* FileException::getPyExceptionType() const
// ---------------------------------------------------------
FileSystemError::FileSystemError()
: Exception()
{}
FileSystemError::FileSystemError() = default;
FileSystemError::FileSystemError(const char* sMessage)
: Exception(sMessage)
@@ -370,9 +373,7 @@ PyObject* FileSystemError::getPyExceptionType() const
// ---------------------------------------------------------
BadFormatError::BadFormatError()
: Exception()
{}
BadFormatError::BadFormatError() = default;
BadFormatError::BadFormatError(const char* sMessage)
: Exception(sMessage)
@@ -404,12 +405,27 @@ MemoryException::MemoryException(const MemoryException& inst)
#endif
{}
MemoryException::MemoryException(MemoryException&& inst) noexcept
#if defined(__GNUC__)
: std::bad_alloc()
, Exception(inst)
#else
: Exception(inst)
#endif
{}
MemoryException& MemoryException::operator=(const MemoryException& inst)
{
Exception::operator=(inst);
return *this;
}
MemoryException& MemoryException::operator=(MemoryException&& inst) noexcept
{
Exception::operator=(inst);
return *this;
}
#if defined(__GNUC__)
const char* MemoryException::what() const noexcept
{
@@ -465,9 +481,7 @@ PyObject* AbnormalProgramTermination::getPyExceptionType() const
// ---------------------------------------------------------
UnknownProgramOption::UnknownProgramOption()
: Exception()
{}
UnknownProgramOption::UnknownProgramOption() = default;
UnknownProgramOption::UnknownProgramOption(const char* sMessage)
: Exception(sMessage)
@@ -484,9 +498,7 @@ PyObject* UnknownProgramOption::getPyExceptionType() const
// ---------------------------------------------------------
ProgramInformation::ProgramInformation()
: Exception()
{}
ProgramInformation::ProgramInformation() = default;
ProgramInformation::ProgramInformation(const char* sMessage)
: Exception(sMessage)
@@ -498,9 +510,7 @@ ProgramInformation::ProgramInformation(const std::string& sMessage)
// ---------------------------------------------------------
TypeError::TypeError()
: Exception()
{}
TypeError::TypeError() = default;
TypeError::TypeError(const char* sMessage)
: Exception(sMessage)
@@ -517,9 +527,7 @@ PyObject* TypeError::getPyExceptionType() const
// ---------------------------------------------------------
ValueError::ValueError()
: Exception()
{}
ValueError::ValueError() = default;
ValueError::ValueError(const char* sMessage)
: Exception(sMessage)
@@ -536,9 +544,7 @@ PyObject* ValueError::getPyExceptionType() const
// ---------------------------------------------------------
IndexError::IndexError()
: Exception()
{}
IndexError::IndexError() = default;
IndexError::IndexError(const char* sMessage)
: Exception(sMessage)
@@ -555,9 +561,7 @@ PyObject* IndexError::getPyExceptionType() const
// ---------------------------------------------------------
NameError::NameError()
: Exception()
{}
NameError::NameError() = default;
NameError::NameError(const char* sMessage)
: Exception(sMessage)
@@ -574,9 +578,7 @@ PyObject* NameError::getPyExceptionType() const
// ---------------------------------------------------------
ImportError::ImportError()
: Exception()
{}
ImportError::ImportError() = default;
ImportError::ImportError(const char* sMessage)
: Exception(sMessage)
@@ -593,9 +595,7 @@ PyObject* ImportError::getPyExceptionType() const
// ---------------------------------------------------------
AttributeError::AttributeError()
: Exception()
{}
AttributeError::AttributeError() = default;
AttributeError::AttributeError(const char* sMessage)
: Exception(sMessage)
@@ -612,9 +612,7 @@ PyObject* AttributeError::getPyExceptionType() const
// ---------------------------------------------------------
RuntimeError::RuntimeError()
: Exception()
{}
RuntimeError::RuntimeError() = default;
RuntimeError::RuntimeError(const char* sMessage)
: Exception(sMessage)
@@ -650,9 +648,7 @@ PyObject* BadGraphError::getPyExceptionType() const
// ---------------------------------------------------------
NotImplementedError::NotImplementedError()
: Exception()
{}
NotImplementedError::NotImplementedError() = default;
NotImplementedError::NotImplementedError(const char* sMessage)
: Exception(sMessage)
@@ -669,9 +665,7 @@ PyObject* NotImplementedError::getPyExceptionType() const
// ---------------------------------------------------------
ZeroDivisionError::ZeroDivisionError()
: Exception()
{}
ZeroDivisionError::ZeroDivisionError() = default;
ZeroDivisionError::ZeroDivisionError(const char* sMessage)
: Exception(sMessage)
@@ -688,9 +682,7 @@ PyObject* ZeroDivisionError::getPyExceptionType() const
// ---------------------------------------------------------
ReferenceError::ReferenceError()
: Exception()
{}
ReferenceError::ReferenceError() = default;
ReferenceError::ReferenceError(const char* sMessage)
: Exception(sMessage)
@@ -707,9 +699,7 @@ PyObject* ReferenceError::getPyExceptionType() const
// ---------------------------------------------------------
ExpressionError::ExpressionError()
: Exception()
{}
ExpressionError::ExpressionError() = default;
ExpressionError::ExpressionError(const char* sMessage)
: Exception(sMessage)
@@ -726,9 +716,7 @@ PyObject* ExpressionError::getPyExceptionType() const
// ---------------------------------------------------------
ParserError::ParserError()
: Exception()
{}
ParserError::ParserError() = default;
ParserError::ParserError(const char* sMessage)
: Exception(sMessage)
@@ -745,9 +733,7 @@ PyObject* ParserError::getPyExceptionType() const
// ---------------------------------------------------------
UnicodeError::UnicodeError()
: Exception()
{}
UnicodeError::UnicodeError() = default;
UnicodeError::UnicodeError(const char* sMessage)
: Exception(sMessage)
@@ -764,9 +750,7 @@ PyObject* UnicodeError::getPyExceptionType() const
// ---------------------------------------------------------
OverflowError::OverflowError()
: Exception()
{}
OverflowError::OverflowError() = default;
OverflowError::OverflowError(const char* sMessage)
: Exception(sMessage)
@@ -783,9 +767,7 @@ PyObject* OverflowError::getPyExceptionType() const
// ---------------------------------------------------------
UnderflowError::UnderflowError()
: Exception()
{}
UnderflowError::UnderflowError() = default;
UnderflowError::UnderflowError(const char* sMessage)
: Exception(sMessage)
@@ -802,9 +784,7 @@ PyObject* UnderflowError::getPyExceptionType() const
// ---------------------------------------------------------
UnitsMismatchError::UnitsMismatchError()
: Exception()
{}
UnitsMismatchError::UnitsMismatchError() = default;
UnitsMismatchError::UnitsMismatchError(const char* sMessage)
: Exception(sMessage)
@@ -821,9 +801,7 @@ PyObject* UnitsMismatchError::getPyExceptionType() const
// ---------------------------------------------------------
CADKernelError::CADKernelError()
: Exception()
{}
CADKernelError::CADKernelError() = default;
CADKernelError::CADKernelError(const char* sMessage)
: Exception(sMessage)
@@ -840,9 +818,7 @@ PyObject* CADKernelError::getPyExceptionType() const
// ---------------------------------------------------------
RestoreError::RestoreError()
: Exception()
{}
RestoreError::RestoreError() = default;
RestoreError::RestoreError(const char* sMessage)
: Exception(sMessage)
+197 -67
View File
@@ -47,6 +47,7 @@ using PyObject = struct _object;
/// have provided one) at that time it gets translated (e.g. in the UI before showing the message of
/// the exception).
// NOLINTBEGIN
#ifdef _MSC_VER
#define THROW(exception) \
@@ -185,6 +186,7 @@ using PyObject = struct _object;
ss << _msg; \
THROWM(_exception, ss.str().c_str()); \
} while (0)
// NOLINTEND
namespace Base
{
@@ -197,6 +199,7 @@ public:
~Exception() noexcept override = default;
Exception& operator=(const Exception& inst);
Exception& operator=(Exception&& inst) noexcept;
virtual const char* what() const noexcept;
@@ -219,8 +222,7 @@ public:
/// setter methods for including debug information
/// intended to use via macro for autofilling of debugging information
inline void
setDebugInformation(const std::string& file, const int line, const std::string& function);
inline void setDebugInformation(const std::string& file, int line, const std::string& function);
inline void setTranslatable(bool translatable);
@@ -245,10 +247,11 @@ protected:
* - a very technical message not intended to be translated or shown to the user in the UI
* The preferred way of throwing an exception is using the macros above.
* This way, the file, line, and function are automatically inserted. */
Exception(const char* sMessage);
Exception(const std::string& sMessage);
explicit Exception(const char* sMessage);
explicit Exception(std::string sMessage);
Exception();
Exception(const Exception& inst);
Exception(Exception&& inst) noexcept;
protected:
std::string _sErrMsg;
@@ -270,12 +273,17 @@ class BaseExport AbortException: public Exception
public:
/// Construction
AbortException(const char* sMessage);
explicit AbortException(const char* sMessage);
/// Construction
AbortException();
AbortException(const AbortException&) = default;
AbortException(AbortException&&) = default;
/// Destruction
~AbortException() noexcept override = default;
AbortException& operator=(const AbortException&) = default;
AbortException& operator=(AbortException&&) = default;
/// Description of the exception
const char* what() const noexcept override;
/// returns the corresponding python exception type
@@ -291,11 +299,16 @@ class BaseExport XMLBaseException: public Exception
public:
/// Construction
XMLBaseException();
XMLBaseException(const char* sMessage);
XMLBaseException(const std::string& sMessage);
explicit XMLBaseException(const char* sMessage);
explicit XMLBaseException(const std::string& sMessage);
XMLBaseException(const XMLBaseException&) = default;
XMLBaseException(XMLBaseException&&) = default;
/// Destruction
~XMLBaseException() noexcept override = default;
XMLBaseException& operator=(const XMLBaseException&) = default;
XMLBaseException& operator=(XMLBaseException&&) = default;
PyObject* getPyExceptionType() const override;
};
@@ -307,14 +320,19 @@ class BaseExport XMLParseException: public XMLBaseException
{
public:
/// Construction
XMLParseException(const char* sMessage);
explicit XMLParseException(const char* sMessage);
/// Construction
XMLParseException(const std::string& sMessage);
explicit XMLParseException(const std::string& sMessage);
/// Construction
XMLParseException();
XMLParseException(const XMLParseException&) = default;
XMLParseException(XMLParseException&&) = default;
/// Destruction
~XMLParseException() noexcept override = default;
XMLParseException& operator=(const XMLParseException&) = default;
XMLParseException& operator=(XMLParseException&&) = default;
/// Description of the exception
const char* what() const noexcept override;
PyObject* getPyExceptionType() const override;
@@ -328,14 +346,19 @@ class BaseExport XMLAttributeError: public XMLBaseException
{
public:
/// Construction
XMLAttributeError(const char* sMessage);
explicit XMLAttributeError(const char* sMessage);
/// Construction
XMLAttributeError(const std::string& sMessage);
explicit XMLAttributeError(const std::string& sMessage);
/// Construction
XMLAttributeError();
XMLAttributeError(const XMLAttributeError&) = default;
XMLAttributeError(XMLAttributeError&&) = default;
/// Destruction
~XMLAttributeError() noexcept override = default;
XMLAttributeError& operator=(const XMLAttributeError&) = default;
XMLAttributeError& operator=(XMLAttributeError&&) = default;
/// Description of the exception
const char* what() const noexcept override;
PyObject* getPyExceptionType() const override;
@@ -349,17 +372,19 @@ class BaseExport FileException: public Exception
{
public:
/// With massage and file name
FileException(const char* sMessage, const char* sFileName = nullptr);
explicit FileException(const char* sMessage, const char* sFileName = nullptr);
/// With massage and file name
FileException(const char* sMessage, const FileInfo& File);
/// standard construction
FileException();
/// Construction
FileException(const FileException&) = default;
FileException(FileException&&) = default;
/// Destruction
~FileException() noexcept override = default;
/// Assignment operator
FileException& operator=(const FileException& inst);
FileException& operator=(const FileException&) = default;
FileException& operator=(FileException&&) = default;
/// Description of the exception
const char* what() const noexcept override;
/// Report generation
@@ -391,10 +416,15 @@ class BaseExport FileSystemError: public Exception
public:
/// Construction
FileSystemError();
FileSystemError(const char* sMessage);
FileSystemError(const std::string& sMessage);
explicit FileSystemError(const char* sMessage);
explicit FileSystemError(const std::string& sMessage);
FileSystemError(const FileSystemError&) = default;
FileSystemError(FileSystemError&&) = default;
/// Destruction
~FileSystemError() noexcept override = default;
FileSystemError& operator=(const FileSystemError&) = default;
FileSystemError& operator=(FileSystemError&&) = default;
PyObject* getPyExceptionType() const override;
};
@@ -407,10 +437,14 @@ class BaseExport BadFormatError: public Exception
public:
/// Construction
BadFormatError();
BadFormatError(const char* sMessage);
BadFormatError(const std::string& sMessage);
explicit BadFormatError(const char* sMessage);
explicit BadFormatError(const std::string& sMessage);
BadFormatError(const BadFormatError&) = default;
BadFormatError(BadFormatError&&) = default;
/// Destruction
~BadFormatError() noexcept override = default;
BadFormatError& operator=(const BadFormatError&) = default;
BadFormatError& operator=(BadFormatError&&) = default;
PyObject* getPyExceptionType() const override;
};
@@ -430,10 +464,12 @@ public:
MemoryException();
/// Construction
MemoryException(const MemoryException& inst);
MemoryException(MemoryException&& inst) noexcept;
/// Destruction
~MemoryException() noexcept override = default;
/// Assignment operator
MemoryException& operator=(const MemoryException& inst);
MemoryException& operator=(MemoryException&& inst) noexcept;
#if defined(__GNUC__)
/// Description of the exception
const char* what() const noexcept override;
@@ -450,10 +486,14 @@ class BaseExport AccessViolation: public Exception
public:
/// Construction
AccessViolation();
AccessViolation(const char* sMessage);
AccessViolation(const std::string& sMessage);
explicit AccessViolation(const char* sMessage);
explicit AccessViolation(const std::string& sMessage);
AccessViolation(const AccessViolation&) = default;
AccessViolation(AccessViolation&&) = default;
/// Destruction
~AccessViolation() noexcept override = default;
AccessViolation& operator=(const AccessViolation&) = default;
AccessViolation& operator=(AccessViolation&&) = default;
PyObject* getPyExceptionType() const override;
};
@@ -467,10 +507,14 @@ public:
/// Construction
AbnormalProgramTermination();
/// Construction
AbnormalProgramTermination(const char* sMessage);
AbnormalProgramTermination(const std::string& sMessage);
explicit AbnormalProgramTermination(const char* sMessage);
explicit AbnormalProgramTermination(const std::string& sMessage);
AbnormalProgramTermination(const AbnormalProgramTermination&) = default;
AbnormalProgramTermination(AbnormalProgramTermination&&) = default;
/// Destruction
~AbnormalProgramTermination() noexcept override = default;
AbnormalProgramTermination& operator=(const AbnormalProgramTermination&) = default;
AbnormalProgramTermination& operator=(AbnormalProgramTermination&&) = default;
PyObject* getPyExceptionType() const override;
};
@@ -483,10 +527,14 @@ class BaseExport UnknownProgramOption: public Exception
public:
/// Construction
UnknownProgramOption();
UnknownProgramOption(const char* sMessage);
UnknownProgramOption(const std::string& sMessage);
explicit UnknownProgramOption(const char* sMessage);
explicit UnknownProgramOption(const std::string& sMessage);
UnknownProgramOption(const UnknownProgramOption&) = default;
UnknownProgramOption(UnknownProgramOption&&) = default;
/// Destruction
~UnknownProgramOption() noexcept override = default;
UnknownProgramOption& operator=(const UnknownProgramOption&) = default;
UnknownProgramOption& operator=(UnknownProgramOption&&) = default;
PyObject* getPyExceptionType() const override;
};
@@ -499,11 +547,15 @@ class BaseExport ProgramInformation: public Exception
public:
/// Construction
ProgramInformation();
ProgramInformation(const char* sMessage);
ProgramInformation(const std::string& sMessage);
explicit ProgramInformation(const char* sMessage);
explicit ProgramInformation(const std::string& sMessage);
ProgramInformation(const ProgramInformation&) = default;
ProgramInformation(ProgramInformation&&) = default;
/// Destruction
~ProgramInformation() noexcept override = default;
ProgramInformation& operator=(const ProgramInformation&) = default;
ProgramInformation& operator=(ProgramInformation&&) = default;
};
/**
@@ -515,10 +567,14 @@ class BaseExport TypeError: public Exception
public:
/// Construction
TypeError();
TypeError(const char* sMessage);
TypeError(const std::string& sMessage);
explicit TypeError(const char* sMessage);
explicit TypeError(const std::string& sMessage);
TypeError(const TypeError&) = default;
TypeError(TypeError&&) = default;
/// Destruction
~TypeError() noexcept override = default;
TypeError& operator=(const TypeError&) = default;
TypeError& operator=(TypeError&&) = default;
PyObject* getPyExceptionType() const override;
};
@@ -531,10 +587,14 @@ class BaseExport ValueError: public Exception
public:
/// Construction
ValueError();
ValueError(const char* sMessage);
ValueError(const std::string& sMessage);
explicit ValueError(const char* sMessage);
explicit ValueError(const std::string& sMessage);
ValueError(const ValueError&) = default;
ValueError(ValueError&&) = default;
/// Destruction
~ValueError() noexcept override = default;
ValueError& operator=(const ValueError&) = default;
ValueError& operator=(ValueError&&) = default;
PyObject* getPyExceptionType() const override;
};
@@ -547,10 +607,14 @@ class BaseExport IndexError: public Exception
public:
/// Construction
IndexError();
IndexError(const char* sMessage);
IndexError(const std::string& sMessage);
explicit IndexError(const char* sMessage);
explicit IndexError(const std::string& sMessage);
IndexError(const IndexError&) = default;
IndexError(IndexError&&) = default;
/// Destruction
~IndexError() noexcept override = default;
IndexError& operator=(const IndexError&) = default;
IndexError& operator=(IndexError&&) = default;
PyObject* getPyExceptionType() const override;
};
@@ -559,10 +623,14 @@ class BaseExport NameError: public Exception
public:
/// Construction
NameError();
NameError(const char* sMessage);
NameError(const std::string& sMessage);
explicit NameError(const char* sMessage);
explicit NameError(const std::string& sMessage);
NameError(const NameError&) = default;
NameError(NameError&&) = default;
/// Destruction
~NameError() noexcept override = default;
NameError& operator=(const NameError&) = default;
NameError& operator=(NameError&&) = default;
PyObject* getPyExceptionType() const override;
};
@@ -571,10 +639,14 @@ class BaseExport ImportError: public Exception
public:
/// Construction
ImportError();
ImportError(const char* sMessage);
ImportError(const std::string& sMessage);
explicit ImportError(const char* sMessage);
explicit ImportError(const std::string& sMessage);
ImportError(const ImportError&) = default;
ImportError(ImportError&&) = default;
/// Destruction
~ImportError() noexcept override = default;
ImportError& operator=(const ImportError&) = default;
ImportError& operator=(ImportError&&) = default;
PyObject* getPyExceptionType() const override;
};
@@ -587,10 +659,14 @@ class BaseExport AttributeError: public Exception
public:
/// Construction
AttributeError();
AttributeError(const char* sMessage);
AttributeError(const std::string& sMessage);
explicit AttributeError(const char* sMessage);
explicit AttributeError(const std::string& sMessage);
AttributeError(const AttributeError&) = default;
AttributeError(AttributeError&&) = default;
/// Destruction
~AttributeError() noexcept override = default;
AttributeError& operator=(const AttributeError&) = default;
AttributeError& operator=(AttributeError&&) = default;
PyObject* getPyExceptionType() const override;
};
@@ -603,10 +679,14 @@ class BaseExport RuntimeError: public Exception
public:
/// Construction
RuntimeError();
RuntimeError(const char* sMessage);
RuntimeError(const std::string& sMessage);
explicit RuntimeError(const char* sMessage);
explicit RuntimeError(const std::string& sMessage);
RuntimeError(const RuntimeError&) = default;
RuntimeError(RuntimeError&&) = default;
/// Destruction
~RuntimeError() noexcept override = default;
RuntimeError& operator=(const RuntimeError&) = default;
RuntimeError& operator=(RuntimeError&&) = default;
PyObject* getPyExceptionType() const override;
};
@@ -619,10 +699,14 @@ class BaseExport BadGraphError: public RuntimeError
public:
/// Construction
BadGraphError();
BadGraphError(const char* sMessage);
BadGraphError(const std::string& sMessage);
explicit BadGraphError(const char* sMessage);
explicit BadGraphError(const std::string& sMessage);
BadGraphError(const BadGraphError&) = default;
BadGraphError(BadGraphError&&) = default;
/// Destruction
~BadGraphError() noexcept override = default;
BadGraphError& operator=(const BadGraphError&) = default;
BadGraphError& operator=(BadGraphError&&) = default;
PyObject* getPyExceptionType() const override;
};
@@ -635,10 +719,14 @@ class BaseExport NotImplementedError: public Exception
public:
/// Construction
NotImplementedError();
NotImplementedError(const char* sMessage);
NotImplementedError(const std::string& sMessage);
explicit NotImplementedError(const char* sMessage);
explicit NotImplementedError(const std::string& sMessage);
NotImplementedError(const NotImplementedError&) = default;
NotImplementedError(NotImplementedError&&) = default;
/// Destruction
~NotImplementedError() noexcept override = default;
NotImplementedError& operator=(const NotImplementedError&) = default;
NotImplementedError& operator=(NotImplementedError&&) = default;
PyObject* getPyExceptionType() const override;
};
@@ -651,10 +739,14 @@ class BaseExport ZeroDivisionError: public Exception
public:
/// Construction
ZeroDivisionError();
ZeroDivisionError(const char* sMessage);
ZeroDivisionError(const std::string& sMessage);
explicit ZeroDivisionError(const char* sMessage);
explicit ZeroDivisionError(const std::string& sMessage);
ZeroDivisionError(const ZeroDivisionError&) = default;
ZeroDivisionError(ZeroDivisionError&&) = default;
/// Destruction
~ZeroDivisionError() noexcept override = default;
ZeroDivisionError& operator=(const ZeroDivisionError&) = default;
ZeroDivisionError& operator=(ZeroDivisionError&&) = default;
PyObject* getPyExceptionType() const override;
};
@@ -667,10 +759,14 @@ class BaseExport ReferenceError: public Exception
public:
/// Construction
ReferenceError();
ReferenceError(const char* sMessage);
ReferenceError(const std::string& sMessage);
explicit ReferenceError(const char* sMessage);
explicit ReferenceError(const std::string& sMessage);
ReferenceError(const ReferenceError&) = default;
ReferenceError(ReferenceError&&) = default;
/// Destruction
~ReferenceError() noexcept override = default;
ReferenceError& operator=(const ReferenceError&) = default;
ReferenceError& operator=(ReferenceError&&) = default;
PyObject* getPyExceptionType() const override;
};
@@ -684,10 +780,14 @@ class BaseExport ExpressionError: public Exception
public:
/// Construction
ExpressionError();
ExpressionError(const char* sMessage);
ExpressionError(const std::string& sMessage);
explicit ExpressionError(const char* sMessage);
explicit ExpressionError(const std::string& sMessage);
ExpressionError(const ExpressionError&) = default;
ExpressionError(ExpressionError&&) = default;
/// Destruction
~ExpressionError() noexcept override = default;
ExpressionError& operator=(const ExpressionError&) = default;
ExpressionError& operator=(ExpressionError&&) = default;
PyObject* getPyExceptionType() const override;
};
@@ -700,10 +800,14 @@ class BaseExport ParserError: public Exception
public:
/// Construction
ParserError();
ParserError(const char* sMessage);
ParserError(const std::string& sMessage);
explicit ParserError(const char* sMessage);
explicit ParserError(const std::string& sMessage);
ParserError(const ParserError&) = default;
ParserError(ParserError&&) = default;
/// Destruction
~ParserError() noexcept override = default;
ParserError& operator=(const ParserError&) = default;
ParserError& operator=(ParserError&&) = default;
PyObject* getPyExceptionType() const override;
};
@@ -716,10 +820,14 @@ class BaseExport UnicodeError: public Exception
public:
/// Construction
UnicodeError();
UnicodeError(const char* sMessage);
UnicodeError(const std::string& sMessage);
explicit UnicodeError(const char* sMessage);
explicit UnicodeError(const std::string& sMessage);
UnicodeError(const UnicodeError&) = default;
UnicodeError(UnicodeError&&) = default;
/// Destruction
~UnicodeError() noexcept override = default;
UnicodeError& operator=(const UnicodeError&) = default;
UnicodeError& operator=(UnicodeError&&) = default;
PyObject* getPyExceptionType() const override;
};
@@ -732,10 +840,14 @@ class BaseExport OverflowError: public Exception
public:
/// Construction
OverflowError();
OverflowError(const char* sMessage);
OverflowError(const std::string& sMessage);
explicit OverflowError(const char* sMessage);
explicit OverflowError(const std::string& sMessage);
OverflowError(const OverflowError&) = default;
OverflowError(OverflowError&&) = default;
/// Destruction
~OverflowError() noexcept override = default;
OverflowError& operator=(const OverflowError&) = default;
OverflowError& operator=(OverflowError&&) = default;
PyObject* getPyExceptionType() const override;
};
@@ -748,10 +860,14 @@ class BaseExport UnderflowError: public Exception
public:
/// Construction
UnderflowError();
UnderflowError(const char* sMessage);
UnderflowError(const std::string& sMessage);
explicit UnderflowError(const char* sMessage);
explicit UnderflowError(const std::string& sMessage);
UnderflowError(const UnderflowError&) = default;
UnderflowError(UnderflowError&&) = default;
/// Destruction
~UnderflowError() noexcept override = default;
UnderflowError& operator=(const UnderflowError&) = default;
UnderflowError& operator=(UnderflowError&&) = default;
PyObject* getPyExceptionType() const override;
};
@@ -764,10 +880,14 @@ class BaseExport UnitsMismatchError: public Exception
public:
/// Construction
UnitsMismatchError();
UnitsMismatchError(const char* sMessage);
UnitsMismatchError(const std::string& sMessage);
explicit UnitsMismatchError(const char* sMessage);
explicit UnitsMismatchError(const std::string& sMessage);
UnitsMismatchError(const UnitsMismatchError&) = default;
UnitsMismatchError(UnitsMismatchError&&) = default;
/// Destruction
~UnitsMismatchError() noexcept override = default;
UnitsMismatchError& operator=(const UnitsMismatchError&) = default;
UnitsMismatchError& operator=(UnitsMismatchError&&) = default;
PyObject* getPyExceptionType() const override;
};
@@ -781,10 +901,14 @@ class BaseExport CADKernelError: public Exception
public:
/// Construction
CADKernelError();
CADKernelError(const char* sMessage);
CADKernelError(const std::string& sMessage);
explicit CADKernelError(const char* sMessage);
explicit CADKernelError(const std::string& sMessage);
CADKernelError(const CADKernelError&) = default;
CADKernelError(CADKernelError&&) = default;
/// Destruction
~CADKernelError() noexcept override = default;
CADKernelError& operator=(const CADKernelError&) = default;
CADKernelError& operator=(CADKernelError&&) = default;
PyObject* getPyExceptionType() const override;
};
@@ -800,10 +924,14 @@ class BaseExport RestoreError: public Exception
public:
/// Construction
RestoreError();
RestoreError(const char* sMessage);
RestoreError(const std::string& sMessage);
explicit RestoreError(const char* sMessage);
explicit RestoreError(const std::string& sMessage);
RestoreError(const RestoreError&) = default;
RestoreError(RestoreError&&) = default;
/// Destruction
~RestoreError() noexcept override = default;
RestoreError& operator=(const RestoreError&) = default;
RestoreError& operator=(RestoreError&&) = default;
PyObject* getPyExceptionType() const override;
};
@@ -844,7 +972,7 @@ inline bool Exception::getTranslatable() const
}
inline void
Exception::setDebugInformation(const std::string& file, const int line, const std::string& function)
Exception::setDebugInformation(const std::string& file, int line, const std::string& function)
{
_file = file;
_line = line;
@@ -867,8 +995,10 @@ private:
static void throw_signal(int signum);
private:
struct sigaction new_action, old_action;
bool ok;
// clang-format off
struct sigaction new_action {}, old_action {};
bool ok {false};
// clang-format on
};
#endif
+3 -5
View File
@@ -33,16 +33,14 @@ ExceptionFactory* ExceptionFactory::_pcSingleton = nullptr; // NOLINT
ExceptionFactory& ExceptionFactory::Instance()
{
if (!_pcSingleton) {
_pcSingleton = new ExceptionFactory;
_pcSingleton = new ExceptionFactory; // NOLINT
}
return *_pcSingleton;
}
void ExceptionFactory::Destruct()
{
if (_pcSingleton) {
delete _pcSingleton;
}
delete _pcSingleton;
_pcSingleton = nullptr;
}
@@ -56,7 +54,7 @@ void ExceptionFactory::raiseException(PyObject* pydict) const
std::map<const std::string, AbstractProducer*>::const_iterator pProd;
pProd = _mpcProducers.find(classname.c_str());
pProd = _mpcProducers.find(classname);
if (pProd != _mpcProducers.end()) {
static_cast<AbstractExceptionProducer*>(pProd->second)->raiseException(pydict);
}

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