Merge branch 'main' into tdx-mac

This commit is contained in:
Patryk Skowroński
2025-01-09 16:07:02 +01:00
committed by GitHub
567 changed files with 30757 additions and 106478 deletions
+1 -4
View File
@@ -1,14 +1,13 @@
---
Checks: 'clang-diagnostic-*,clang-analyzer-*,boost-*,bugprone-*,
performance-*,readability-*,portability-*,modernize-*,cppcoreguidelines-*,google-explicit-constructor,
concurrency-*,-modernize-use-trailing-return-type, -modernize-use-nodiscard,
concurrency-*,-modernize-use-trailing-return-type, -modernize-use-nodiscard,-readability-identifier-length,
-readability-redundant-access-specifiers,-readability-qualified-auto,
-cppcoreguidelines-avoid-non-const-global-variables,-cppcoreguidelines-owning-memory,
-readability-convert-member-functions-to-static,-bugprone-easily-swappable-parameters,
-cppcoreguidelines-pro-type-static-cast-downcast'
WarningsAsErrors: ''
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle: file
User: florians
CheckOptions:
@@ -150,8 +149,6 @@ CheckOptions:
value: '0'
- key: concurrency-mt-unsafe.FunctionSet
value: any
- key: readability-identifier-length.IgnoredExceptionVariableNames
value: '^[e]$'
- key: google-readability-braces-around-statements.ShortStatementLines
value: '1'
- key: bugprone-reserved-identifier.AllowedIdentifiers
+18
View File
@@ -0,0 +1,18 @@
{
"__comment": "Taken from vscode-cpptools's Extension/package.json gcc rule",
"problemMatcher": [
{
"owner": "gcc-problem-matcher",
"pattern": [
{
"regexp": "^(.*):(\\d+):(\\d+):\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
]
}
]
}
+19
View File
@@ -0,0 +1,19 @@
{
"__comment": "Taken from vscode's vs/workbench/contrib/tasks/common/problemMatcher.ts msCompile rule",
"problemMatcher": [
{
"owner": "msvc-problem-matcher",
"pattern": [
{
"regexp": "^(?:\\s+\\d+\\>)?([^\\s].*)\\((\\d+),?(\\d+)?(?:,\\d+,\\d+)?\\)\\s*:\\s+(error|warning|info)\\s+(\\w{1,2}\\d+)\\s*:\\s*(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"code": 5,
"message": 6
}
]
}
]
}
@@ -40,6 +40,13 @@ inputs:
runs:
using: "composite"
steps:
- name: C++ Assembly tests
id: assembly
uses: ./.github/workflows/actions/runCPPTests/runSingleTest
with:
testCommand: ${{ inputs.builddir }}/tests/Tests_run --gtest_output=json:${{ inputs.reportdir }}assembly_gtest_results.json
testLogFile: ${{ inputs.reportdir }}assembly_gtest_test_log.txt
testName: Assembly
- name: C++ core tests
id: core
uses: ./.github/workflows/actions/runCPPTests/runSingleTest
@@ -54,6 +61,13 @@ runs:
testCommand: ${{ inputs.builddir }}/tests/Material_tests_run --gtest_output=json:${{ inputs.reportdir }}material_gtest_results.json
testLogFile: ${{ inputs.reportdir }}material_gtest_test_log.txt
testName: Material
- name: C++ Measure tests
id: measure
uses: ./.github/workflows/actions/runCPPTests/runSingleTest
with:
testCommand: ${{ inputs.builddir }}/tests/Material_tests_run --gtest_output=json:${{ inputs.reportdir }}measure_gtest_results.json
testLogFile: ${{ inputs.reportdir }}measure_gtest_test_log.txt
testName: Measure
- name: C++ Mesh tests
id: mesh
uses: ./.github/workflows/actions/runCPPTests/runSingleTest
@@ -61,6 +75,13 @@ runs:
testCommand: ${{ inputs.builddir }}/tests/Mesh_tests_run --gtest_output=json:${{ inputs.reportdir }}mesh_gtest_results.json
testLogFile: ${{ inputs.reportdir }}mesh_gtest_test_log.txt
testName: Mesh
- name: C++ MeshPart tests
id: meshpart
uses: ./.github/workflows/actions/runCPPTests/runSingleTest
with:
testCommand: ${{ inputs.builddir }}/tests/Mesh_tests_run --gtest_output=json:${{ inputs.reportdir }}meshpart_gtest_results.json
testLogFile: ${{ inputs.reportdir }}meshpart_gtest_test_log.txt
testName: MeshPart
- name: C++ Part tests
id: part
uses: ./.github/workflows/actions/runCPPTests/runSingleTest
@@ -89,6 +110,13 @@ runs:
testCommand: ${{ inputs.builddir }}/tests/Sketcher_tests_run --gtest_output=json:${{ inputs.reportdir }}sketcher_gtest_results.json
testLogFile: ${{ inputs.reportdir }}sketcher_gtest_test_log.txt
testName: Sketcher
- name: C++ Spreadsheet tests
id: spreadsheet
uses: ./.github/workflows/actions/runCPPTests/runSingleTest
with:
testCommand: ${{ inputs.builddir }}/tests/Sketcher_tests_run --gtest_output=json:${{ inputs.reportdir }}spreadsheet_gtest_results.json
testLogFile: ${{ inputs.reportdir }}spreadsheet_gtest_test_log.txt
testName: Spreadsheet
- name: Compose summary report based on test results
if: always()
shell: bash -l {0}
+16 -1
View File
@@ -83,6 +83,21 @@ jobs:
- name: Checkout
uses: actions/checkout@v2
- name: Add GCC Problem Matcher
if: runner.os == 'Linux'
run: |
echo "::add-matcher::${{ runner.workspace }}/FreeCAD/.github/problemMatcher/gcc.json"
- name: Add Clang Problem Matcher
if: runner.os == 'macOS'
run: |
echo "::add-matcher::${{ runner.workspace }}/FreeCAD/.github/problemMatcher/clang.json"
- name: Add MSVC++ Problem Matcher
if: runner.os == 'Windows'
run: |
echo "::add-matcher::${{ runner.workspace }}/FreeCAD/.github/problemMatcher/msvc.json"
- name: Make needed directories, files and initializations
id: Init
run: |
@@ -93,7 +108,7 @@ jobs:
- uses: prefix-dev/[email protected]
with:
pixi-version: v0.34.0
pixi-version: v0.39.4
cache: false
- name: Restore Compiler Cache
+1 -1
View File
@@ -67,6 +67,6 @@ repos:
- id: black
args: ['--line-length', '100']
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: 7d85583be209cb547946c82fbe51f4bc5dd1d017 # frozen: v18.1.8
rev: fed9a1f62c22af0bc846a260ebfeb0844368fd93 # frozen: v19.1.4
hooks:
- id: clang-format
+2 -2
View File
@@ -26,7 +26,7 @@ The FreeCAD Contribution Process is expressed here with the following specific g
1. FreeCAD uses the git distributed revision control system.
2. Source code for the main application and related subprojects is hosted on github.com in the FreeCAD organization.
3. Problems are discrete, well-defined limitations or bugs.
4. FreeCAD uses GitHub's issue-tracking system to track problems and contributions. For help requests and general discussions, use the project forum.
4. FreeCAD uses GitHub's issue-tracking system to track problems and contributions. For help requests and general discussions, use the project forum.
5. Contributions are sets of code changes that resolve a single problem.
6. FreeCAD uses the Pull Request workflow for evaluating and accepting contributions.
@@ -47,7 +47,7 @@ The FreeCAD Contribution Process is expressed here with the following specific g
## 5. Contribution Requirements
1. Contributions are submitted in the form of Pull Requests (PR).
2. Maintainers and Contributors MUST have a GitHub account and SHOULD use their real names or a well-known alias.
2. Maintainers and Contributors MUST have a GitHub account and SHOULD use their real names or a well-known alias.
3. If the GitHub username differs from the username on the FreeCAD Forum, effort SHOULD be taken to avoid confusion.
4. A PR SHOULD be a minimal and accurate answer to exactly one identified and agreed-on problem.
5. A PR SHOULD refrain from adding additional dependencies to the FreeCAD project unless no other option is available.
+4 -8
View File
@@ -4,10 +4,7 @@ The FreeCAD application does not collect, transmit, share or use any Personal Da
FreeCAD is community-developed Free Software. The community does not condone the unauthorized usage of private data, so our software does not gather or send personal data.
The FreeCAD website is mostly static, it does not contain any trackers, neither ours nor third-party. The website uses cookies to remember logged in status, timezone and other
data related to navigating the site.
The website does not contain advertisements.
The FreeCAD website is mostly static, it does not contain any trackers, neither ours nor third-party. The website uses cookies to remember logged in status, timezone and other data related to navigating the site. The website does not contain advertisements.
The software does not contain advertisements or trackers either.
@@ -15,9 +12,9 @@ The software does not contain advertisements or trackers either.
FreeCAD is able to load or save files to/from remote servers (for some protocols and platforms). If you choose to load or save a remote file, your IP or other private data might be shared as part of the normal connection flow for the given protocol. This is out of our control and it is up to you to decide whether you trust a remote host.
The FreeCAD eco system includes user developed workbenches. These workbenches can be installed/updated using the Add-on Manager. The Add-on Manager retrieves workbenches from remote servers across the internet. Add-on workbenches are not checked for malicious content. It is your responsibility to decide whether you trust an add-on workbench.
The FreeCAD eco system includes user developed workbenches. These workbenches can be installed/updated using the Add-on Manager. The Add-on Manager retrieves workbenches from remote servers across the internet. Add-on workbenches are not checked for malicious content. It is your responsibility to decide whether you trust an add-on workbench.
FreeCAD is meant to manipulate CAD files which may contain metadata. It is your responsibility to verify the metadata contained in your files before you share them with others. These files may contain local directory paths which could reveal user names if the user name forms part of the path - as in “C:\MrsCAD\Documents\myFreeCADFile.FCstd”.
FreeCAD is meant to manipulate CAD files which may contain metadata. It is your responsibility to verify the metadata contained in your files before you share them with others. These files may contain local directory paths which could reveal user names if the user name forms part of the path - as in “C:\MrsCAD\Documents\myFreeCADFile.FCstd”.
FreeCAD can also be used to create and run macros. These are Python scripts that can perform any action that the user can perform on a system. When running a macro from an outside source, it is your responsibility to ensure you trust the author.
@@ -28,5 +25,4 @@ When reading the online version of the User Manual within FreeCAD, manual conten
FreeCAD is Free Software and therefore may be packaged by other people, who may include additional software or modify the source code. We do not vouch for these third-party packages and cannot tell you what they contain and what they do regarding your privacy. The official packages are explicitly listed in our download page.
- [based on the GIMP privacy policy](https://www.gimp.org/about/privacy.html)
*The above privacy policy is based on the [GIMP privacy policy](https://www.gimp.org/about/privacy.html).*
+5 -5
View File
@@ -1,18 +1,18 @@
# Security Policy
The FreeCAD project is a FOSS (Free and Open-Source Software) project that has a community of thousands of users and
The FreeCAD project is a FOSS (Free and Open-Source Software) project that has a community of thousands of users and
hundreds of developers worldwide. We encourage responsible reporting of security vulnerabilities that may affect users
of this software, and will endeavor to address these vulnerabilities when they are discovered.
## Bounties
FreeCAD does not have a program to pay bounties for security bugs. If you discover a vulnerability that affects a part
of the FreeCAD project (either directly in FreeCAD, in a library it depends on, or in any of the various other
FreeCAD does not have a program to pay bounties for security bugs. If you discover a vulnerability that affects a part
of the FreeCAD project (either directly in FreeCAD, in a library it depends on, or in any of the various other
subprojects such as our website, forums, etc.) we ask you to join the large community of volunteer contributors and
file a report about the issue.
Note that funds may be available from the [FreeCAD Project Association (FPA)](https://fpa.freecad.org) to pursue
security research and/or the development of fixes to any vulnerabilities discovered. However, vulnerabilities held as
Note that funds may be available from the [FreeCAD Project Association (FPA)](https://fpa.freecad.org) to pursue
security research and/or the development of fixes to any vulnerabilities discovered. However, vulnerabilities held as
hostage in demands for "bounties" will not be entertained. Contact the FPA at fpa@freecad.org for more information.
## Supported Versions
+1 -1
View File
@@ -118,7 +118,7 @@ if(PYCXX_FOUND)
${PYCXX_SOURCE_DIR}/IndirectPythonInterface.cxx
)
#set old 6.2 pycxx compatibility
#set old 6.2 pycxx compatibility
list(APPEND PYCXX_SOURCES ${PYCXX_SOURCE_DIR}/cxx_exceptions.cxx)
add_definitions(-DPYCXX_6_2_COMPATIBILITY)
#end old compatibility
@@ -170,7 +170,7 @@ macro(InitializeFreeCADBuildOptions)
if(MSVC)
option(BUILD_FEM_NETGEN "Build the FreeCAD FEM module with the NETGEN mesher" ON)
option(FREECAD_USE_PCL "Build the features that use PCL libs" OFF) # 3/5/2021 current LibPack uses non-C++17 FLANN
option(FREECAD_USE_PCL "Build the features that use PCL libs" OFF)
endif(MSVC)
if(NOT MSVC)
option(BUILD_FEM_NETGEN "Build the FreeCAD FEM module with the NETGEN mesher" OFF)
@@ -179,7 +179,10 @@ macro(InitializeFreeCADBuildOptions)
# if this is set override some options
if (FREECAD_BUILD_DEBIAN)
set(FREECAD_USE_EXTERNAL_ZIPIOS ON )
# Disable it until the upstream package has been fixed. See
# https://github.com/FreeCAD/FreeCAD/issues/13676#issuecomment-2539978468
# https://github.com/FreeCAD/FreeCAD/issues/13676#issuecomment-2541513308
set(FREECAD_USE_EXTERNAL_ZIPIOS OFF )
# A Debian package for SMESH doesn't exist
#set(FREECAD_USE_EXTERNAL_SMESH ON )
endif (FREECAD_BUILD_DEBIAN)
+11002 -17912
View File
File diff suppressed because it is too large Load Diff
+5 -2
View File
@@ -3,7 +3,7 @@ name = "FreeCAD"
version = "0.22.0"
description = "pixi instructions for FreeCAD"
authors = ["looooo <[email protected]>"]
channels = ["conda-forge/label/pivy_rc", "conda-forge"]
channels = ["conda-forge"]
platforms = [ "linux-64", "linux-aarch64", "osx-64", "osx-arm64", "win-64" ]
[dependencies]
@@ -34,7 +34,7 @@ ply = "*"
pre-commit = "*"
pybind11 = "*"
pyside6 = "*"
python = "3.12"
python = "3.13"
pyyaml = "*"
qt6-main = "*"
scipy = ">=1.14.1,<2"
@@ -75,6 +75,7 @@ sed = "*"
sysroot_linux-64 = "*"
xorg-x11-server-common-cos6-x86_64 = "*"
xorg-x11-server-xvfb-cos6-x86_64 = "*"
xorg-xproto = "*"
## Linux Dependencies (aarch64)
[target.linux-aarch64.dependencies]
@@ -108,6 +109,7 @@ sed = "*"
sysroot_linux-aarch64 = "*"
xorg-x11-server-common-cos7-aarch64 = "*"
xorg-x11-server-xvfb-cos7-aarch64 = "*"
xorg-xproto = "*"
## macOS Dependencies (Intel)
[target.osx-64.dependencies]
@@ -142,6 +144,7 @@ configure-release = { cmd = [ "cmake", "-B", "build", "--preset", "conda-macos-r
configure = { cmd = [ "cmake", "-B", "build", "--preset", "conda-windows-debug", "-DFREECAD_QT_VERSION=6", "-DBUILD_REVERSEENGINEERING=OFF" ], depends-on = ["initialize"]}
configure-debug = { cmd = [ "cmake", "-B", "build", "--preset", "conda-windows-debug", "-DFREECAD_QT_VERSION=6", "-DBUILD_REVERSEENGINEERING=OFF" ], depends-on = ["initialize"]}
configure-release = { cmd = [ "cmake", "-B", "build", "--preset", "conda-windows-release", "-DFREECAD_QT_VERSION=6", "-DBUILD_REVERSEENGINEERING=OFF" ], depends-on = ["initialize"]}
freecad = { cmd = [ ".pixi/envs/default/Library/bin/FreeCAD.exe" ], depends-on = ["install"]}
## Tasks
[tasks]
+10 -7
View File
@@ -32,6 +32,7 @@
#include <vtkDoubleArray.h>
#include <vtkIdTypeArray.h>
#include <vtkUnsignedCharArray.h>
#include <vtkVersionMacros.h>
#include <list>
#include <climits>
@@ -249,14 +250,16 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<int>& idNodesOldToNew, int n
}
}
if (this->FaceLocations)
vtkIdTypeArray* thisFaceLocations = GetFaceLocations();
vtkIdTypeArray* thisFaces = GetFaces();
if (thisFaceLocations)
{
vtkIdTypeArray *newFaceLocations = vtkIdTypeArray::New();
newFaceLocations->Initialize();
newFaceLocations->Allocate(newTypes->GetSize());
vtkIdTypeArray *newFaces = vtkIdTypeArray::New();
newFaces->Initialize();
newFaces->Allocate(this->Faces->GetSize());
newFaces->Allocate(thisFaces->GetSize());
for (int i = 0; i < oldCellSize; i++)
{
if (this->Types->GetValue(i) == VTK_EMPTY_CELL)
@@ -265,16 +268,16 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<int>& idNodesOldToNew, int n
if (newTypes->GetValue(newCellId) == VTK_POLYHEDRON)
{
newFaceLocations->InsertNextValue(newFaces->GetMaxId()+1);
int oldFaceLoc = this->FaceLocations->GetValue(i);
int nCellFaces = this->Faces->GetValue(oldFaceLoc++);
int oldFaceLoc = thisFaceLocations->GetValue(i);
int nCellFaces = thisFaces->GetValue(oldFaceLoc++);
newFaces->InsertNextValue(nCellFaces);
for (int n=0; n<nCellFaces; n++)
{
int nptsInFace = this->Faces->GetValue(oldFaceLoc++);
int nptsInFace = thisFaces->GetValue(oldFaceLoc++);
newFaces->InsertNextValue(nptsInFace);
for (int k=0; k<nptsInFace; k++)
{
int oldpt = this->Faces->GetValue(oldFaceLoc++);
int oldpt = thisFaces->GetValue(oldFaceLoc++);
newFaces->InsertNextValue(idNodesOldToNew[oldpt]);
}
}
@@ -292,7 +295,7 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<int>& idNodesOldToNew, int n
}
else
{
this->SetCells(newTypes, newLocations, newConnectivity, FaceLocations, Faces);
this->SetCells(newTypes, newLocations, newConnectivity, thisFaceLocations, thisFaces);
}
newPoints->Delete();
+13 -2
View File
@@ -2060,6 +2060,7 @@ void Application::initTypes()
App::PropertyElectricCharge ::init();
App::PropertyElectricCurrent ::init();
App::PropertyElectricPotential ::init();
App::PropertyElectromagneticPotential ::init();
App::PropertyFrequency ::init();
App::PropertyForce ::init();
App::PropertyHeatFlux ::init();
@@ -2251,6 +2252,7 @@ void parseProgramOptions(int ac, char ** av, const string& exe, variables_map& v
("run-test,t", value<string>()->implicit_value(""),"Run a given test case (use 0 (zero) to run all tests). If no argument is provided then return list of all available tests.")
("run-open,r", value<string>()->implicit_value(""),"Run a given test case (use 0 (zero) to run all tests). If no argument is provided then return list of all available tests. Keeps UI open after test(s) complete.")
("module-path,M", value< vector<string> >()->composing(),"Additional module paths")
("macro-path,E", value< vector<string> >()->composing(),"Additional macro paths")
("python-path,P", value< vector<string> >()->composing(),"Additional python paths")
("disable-addon", value< vector<string> >()->composing(),"Disable a given addon.")
("single-instance", "Allow to run a single instance of the application")
@@ -2293,7 +2295,7 @@ void parseProgramOptions(int ac, char ** av, const string& exe, variables_map& v
#endif
;
//0000723: improper handling of qt specific command line arguments
std::vector<std::string> args;
bool merge=false;
@@ -2428,6 +2430,15 @@ void processProgramOptions(const variables_map& vm, std::map<std::string,std::st
mConfig["AdditionalModulePaths"] = temp;
}
if (vm.count("macro-path")) {
vector<string> Macros = vm["macro-path"].as< vector<string> >();
string temp;
for (const auto & It : Macros)
temp += It + ";";
temp.erase(temp.end()-1);
mConfig["AdditionalMacroPaths"] = temp;
}
if (vm.count("python-path")) {
vector<string> Paths = vm["python-path"].as< vector<string> >();
for (const auto & It : Paths)
@@ -2592,7 +2603,7 @@ void Application::initConfig(int argc, char ** argv)
// extract home paths
ExtractUserPath();
if (vm.count("safe-mode")) {
SafeMode::StartSafeMode();
}
+66 -17
View File
@@ -1,24 +1,23 @@
/***************************************************************************
* Copyright (c) 2015 Stefan Tröger <[email protected]> *
* Copyright (c) 2015 Stefan Tröger <[email protected]> *
* Copyright (c) 2015 Alexander Golubev (Fat-Zer) <[email protected]> *
* Copyright (c) 2024 Ondsel (PL Boyer) <[email protected]> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* 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. *
* *
* This library 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. *
* 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 Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
@@ -207,9 +206,9 @@ const std::vector<LocalCoordinateSystem::SetupData>& LocalCoordinateSystem::getS
{
static const std::vector<SetupData> setupData = {
// clang-format off
{App::Line::getClassTypeId(), AxisRoles[0], tr("X-axis"), Base::Rotation()},
{App::Line::getClassTypeId(), AxisRoles[1], tr("Y-axis"), Base::Rotation(Base::Vector3d(1, 1, 1), M_PI * 2 / 3)},
{App::Line::getClassTypeId(), AxisRoles[2], tr("Z-axis"), Base::Rotation(Base::Vector3d(1,-1, 1), M_PI * 2 / 3)},
{App::Line::getClassTypeId(), AxisRoles[0], tr("X-axis"), Base::Rotation(Base::Vector3d(1, 1, 1), M_PI * 2 / 3)},
{App::Line::getClassTypeId(), AxisRoles[1], tr("Y-axis"), Base::Rotation(Base::Vector3d(-1, 1, 1), M_PI * 2 / 3)},
{App::Line::getClassTypeId(), AxisRoles[2], tr("Z-axis"), Base::Rotation()},
{App::Plane::getClassTypeId(), PlaneRoles[0], tr("XY-plane"), Base::Rotation()},
{App::Plane::getClassTypeId(), PlaneRoles[1], tr("XZ-plane"), Base::Rotation(1.0, 0.0, 0.0, 1.0)},
{App::Plane::getClassTypeId(), PlaneRoles[2], tr("YZ-plane"), Base::Rotation(Base::Vector3d(1, 1, 1), M_PI * 2 / 3)},
@@ -277,6 +276,56 @@ void LocalCoordinateSystem::unsetupObject()
}
}
void LocalCoordinateSystem::onDocumentRestored()
{
GeoFeature::onDocumentRestored();
// In 0.22 origins did not have point.
migrateOriginPoint();
// In 0.22 the axis placement were wrong. The X axis had identity placement instead of the Z.
// This was fixed but we need to migrate old files.
migrateXAxisPlacement();
}
void LocalCoordinateSystem::migrateOriginPoint()
{
auto features = OriginFeatures.getValues();
auto isOrigin = [](App::DocumentObject* obj) {
return obj->isDerivedFrom<App::DatumElement>() &&
strcmp(static_cast<App::DatumElement*>(obj)->Role.getValue(), PointRoles[0]) == 0;
};
if (std::none_of(features.begin(), features.end(), isOrigin)) {
auto data = getData(PointRoles[0]);
auto* origin = createDatum(data);
features.push_back(origin);
OriginFeatures.setValues(features);
}
}
void LocalCoordinateSystem::migrateXAxisPlacement()
{
constexpr const double tolerance = 1e-5;
auto features = OriginFeatures.getValues();
const auto& setupData = getSetupData();
for (auto* obj : features) {
auto* feature = dynamic_cast <App::DatumElement*> (obj);
if (!feature) { continue; }
for (auto data : setupData) {
// ensure the rotation is correct for the role
if (std::strcmp(feature->Role.getValue(), data.role) == 0) {
if (!feature->Placement.getValue().getRotation().isSame(data.rot, tolerance)) {
feature->Placement.setValue(Base::Placement(Base::Vector3d(), data.rot));
getDocument()->setStatus(App::Document::MigrateLCS, true);
}
break;
}
}
}
}
// ----------------------------------------------------------------------------
LocalCoordinateSystem::LCSExtension::LCSExtension(LocalCoordinateSystem* obj)
+17 -14
View File
@@ -3,22 +3,21 @@
* Copyright (c) 2015 Alexander Golubev (Fat-Zer) <[email protected]> *
* Copyright (c) 2024 Ondsel (PL Boyer) <[email protected]> *
* *
* This file is part of the FreeCAD CAx development system. *
* This file is part of FreeCAD. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* 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. *
* *
* This library 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. *
* 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 Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
@@ -201,7 +200,7 @@ public:
virtual bool isOrigin()
{
return false;
};
}
// Axis links
PropertyLinkList OriginFeatures;
@@ -213,6 +212,7 @@ protected:
void setupObject() override;
/// Removes all planes and axis if they are still linked to the document
void unsetupObject() override;
void onDocumentRestored() override;
private:
struct SetupData;
@@ -245,6 +245,9 @@ private:
DatumElement* createDatum(SetupData& data);
SetupData getData(const char* role);
void migrateOriginPoint();
void migrateXAxisPlacement();
};
} // namespace App
+1
View File
@@ -77,6 +77,7 @@ public:
LinkStampChanged = 11, // Indicates during restore time if any linked document's time stamp has changed
IgnoreErrorOnRecompute = 12, // Don't report errors if the recompute failed
RecomputeOnRestore = 13, // Mark pending recompute on restore for migration purposes
MigrateLCS = 14 // Migrate local coordinate system of older versions
};
// clang-format on
+5 -49
View File
@@ -2294,7 +2294,7 @@ Py::Object FunctionExpression::evaluate(const Expression *expr, int f, const std
return Py::String(args[0]->getPyValue().as_string());
case PARSEQUANT: {
auto quantity_text = args[0]->getPyValue().as_string();
auto quantity_object = Quantity::parse(QString::fromStdString(quantity_text));
auto quantity_object = Quantity::parse(quantity_text);
return Py::asObject(new QuantityPy(new Quantity(quantity_object)));
}
case TRANSLATIONM: {
@@ -2453,56 +2453,12 @@ Py::Object FunctionExpression::evaluate(const Expression *expr, int f, const std
case ABS:
unit = v1.getUnit();
break;
case SQRT: {
unit = v1.getUnit();
// All components of unit must be either zero or dividable by 2
UnitSignature s = unit.getSignature();
if ( !((s.Length % 2) == 0) &&
((s.Mass % 2) == 0) &&
((s.Time % 2) == 0) &&
((s.ElectricCurrent % 2) == 0) &&
((s.ThermodynamicTemperature % 2) == 0) &&
((s.AmountOfSubstance % 2) == 0) &&
((s.LuminousIntensity % 2) == 0) &&
((s.Angle % 2) == 0))
_EXPR_THROW("All dimensions must be even to compute the square root.",expr);
unit = Unit(s.Length /2,
s.Mass / 2,
s.Time / 2,
s.ElectricCurrent / 2,
s.ThermodynamicTemperature / 2,
s.AmountOfSubstance / 2,
s.LuminousIntensity / 2,
s.Angle);
case SQRT:
unit = v1.getUnit().sqrt();
break;
}
case CBRT: {
unit = v1.getUnit();
// All components of unit must be either zero or dividable by 3
UnitSignature s = unit.getSignature();
if ( !((s.Length % 3) == 0) &&
((s.Mass % 3) == 0) &&
((s.Time % 3) == 0) &&
((s.ElectricCurrent % 3) == 0) &&
((s.ThermodynamicTemperature % 3) == 0) &&
((s.AmountOfSubstance % 3) == 0) &&
((s.LuminousIntensity % 3) == 0) &&
((s.Angle % 3) == 0))
_EXPR_THROW("All dimensions must be multiples of 3 to compute the cube root.",expr);
unit = Unit(s.Length /3,
s.Mass / 3,
s.Time / 3,
s.ElectricCurrent / 3,
s.ThermodynamicTemperature / 3,
s.AmountOfSubstance / 3,
s.LuminousIntensity / 3,
s.Angle);
case CBRT:
unit = v1.getUnit().cbrt();
break;
}
case ATAN2:
if (e2.isNone())
_EXPR_THROW("Invalid second argument.",expr);
+2 -1
View File
@@ -98,7 +98,8 @@ def InitApplications():
LibFcDir = os.path.realpath(LibFcDir)
if (os.path.exists(LibFcDir) and not LibFcDir in libpaths):
libpaths.append(LibFcDir)
AddPath = FreeCAD.ConfigGet("AdditionalModulePaths").split(";")
AddPath = FreeCAD.ConfigGet("AdditionalModulePaths").split(";") + \
FreeCAD.ConfigGet("AdditionalMacroPaths").split(";")
HomeMod = FreeCAD.getUserAppDataDir()+"Mod"
HomeMod = os.path.realpath(HomeMod)
MacroStd = App.getUserMacroDir(False)
+1 -1
View File
@@ -134,7 +134,7 @@ ElementNamePair GeoFeature::_getElementName(const char* name,
}
}
DocumentObject* GeoFeature::resolveElement(DocumentObject* obj,
DocumentObject* GeoFeature::resolveElement(const DocumentObject* obj,
const char* subname,
ElementNamePair& elementName,
bool append,
+1 -1
View File
@@ -104,7 +104,7 @@ public:
*
* @return Return the owner object of the element
*/
static DocumentObject* resolveElement(App::DocumentObject* obj,
static DocumentObject* resolveElement(const App::DocumentObject* obj,
const char* subname,
ElementNamePair& elementName,
bool append = false,
+1
View File
@@ -213,6 +213,7 @@ struct PropertyCleaner
auto p = _RemovedProps.back();
_RemovedProps.pop_back();
if (p != prop) {
p->setContainer(nullptr);
delete p;
}
else {
+2 -2
View File
@@ -1621,10 +1621,10 @@ void PropertyString::setPathValue(const ObjectIdentifier& path, const boost::any
setValue(std::to_string(App::any_cast<float>(value)));
}
else if (value.type() == typeid(Quantity)) {
setValue(boost::any_cast<Quantity>(value).getUserString().toUtf8().constData());
setValue(boost::any_cast<Quantity>(value).getUserString().c_str());
}
else if (value.type() == typeid(std::string)) {
setValue(boost::any_cast<const std::string&>(value));
setValue(boost::any_cast<const std::string &>(value));
}
else {
Base::PyGILStateLocker lock;
+18 -3
View File
@@ -48,7 +48,9 @@ TYPESYSTEM_SOURCE(App::PropertyQuantity, App::PropertyFloat)
Base::Quantity PropertyQuantity::getQuantityValue() const
{
return Quantity(_dValue, _Unit);
Quantity quantity(_dValue, _Unit);
quantity.setFormat(_Format);
return quantity;
}
const char* PropertyQuantity::getEditorName() const
@@ -66,7 +68,7 @@ Base::Quantity PropertyQuantity::createQuantityFromPy(PyObject* value)
Base::Quantity quant;
if (PyUnicode_Check(value)) {
quant = Quantity::parse(QString::fromUtf8(PyUnicode_AsUTF8(value)));
quant = Quantity::parse(PyUnicode_AsUTF8(value));
}
else if (PyFloat_Check(value)) {
quant = Quantity(PyFloat_AsDouble(value), _Unit);
@@ -129,7 +131,9 @@ void PropertyQuantity::setPathValue(const ObjectIdentifier& /*path*/, const boos
const boost::any PropertyQuantity::getPathValue(const ObjectIdentifier& /*path*/) const
{
return Quantity(_dValue, _Unit);
Quantity quantity(_dValue, _Unit);
quantity.setFormat(_Format);
return quantity;
}
//**************************************************************************
@@ -554,6 +558,17 @@ PropertyMagnetization::PropertyMagnetization()
setUnit(Base::Unit::Magnetization);
}
//**************************************************************************
// PropertyElectromagneticPotential
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TYPESYSTEM_SOURCE(App::PropertyElectromagneticPotential, App::PropertyQuantity)
PropertyElectromagneticPotential::PropertyElectromagneticPotential()
{
setUnit(Base::Unit::ElectromagneticPotential);
}
//**************************************************************************
// PropertyMass
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+23
View File
@@ -73,6 +73,15 @@ public:
return PropertyFloat::getValue();
}
const Base::QuantityFormat& getFormat() const
{
return _Format;
}
void setFormat(const Base::QuantityFormat& fmt)
{
_Format = fmt;
}
void setPathValue(const App::ObjectIdentifier& path, const boost::any& value) override;
const boost::any getPathValue(const App::ObjectIdentifier& path) const override;
@@ -89,6 +98,7 @@ public:
protected:
Base::Quantity createQuantityFromPy(PyObject* value);
Base::Unit _Unit;
Base::QuantityFormat _Format;
};
/** Float with Unit property
@@ -546,6 +556,19 @@ public:
~PropertyMagnetization() override = default;
};
/** ElectromagneticPotential property
* This is a property for representing electromagnetic potentials. It is basically a float
* property. On the Gui it has a quantity like Wb/m.
*/
class AppExport PropertyElectromagneticPotential: public PropertyQuantity
{
TYPESYSTEM_HEADER_WITH_OVERRIDE();
public:
PropertyElectromagneticPotential();
~PropertyElectromagneticPotential() override = default;
};
/** Mass property
* This is a property for representing mass. It is basically a float
* property. On the Gui it has a quantity like kg.
+3 -1
View File
@@ -256,6 +256,7 @@ SET(FreeCADBase_CPP_SRCS
Rotation.cpp
RotationPyImp.cpp
Sequencer.cpp
ServiceProvider.cpp
SmartPtrPy.cpp
Stream.cpp
Swap.cpp
@@ -319,6 +320,7 @@ SET(FreeCADBase_HPP_SRCS
QtTools.h
Reader.h
Rotation.h
ServiceProvider.h
Sequencer.h
SmartPtrPy.h
Stream.h
@@ -356,7 +358,7 @@ IF (MSVC)
${FreeCADBase_SRCS}
StackWalker.cpp
StackWalker.h
)
)
ENDIF(MSVC)
# Use external zipios++ if specified.
+4 -12
View File
@@ -431,9 +431,7 @@ bool FileInfo::isDir() const
return ((st.st_mode & _S_IFDIR) != 0);
#elif defined(FC_OS_LINUX) || defined(FC_OS_CYGWIN) || defined(FC_OS_MACOSX) || defined(FC_OS_BSD)
struct stat st
{
};
struct stat st {};
if (stat(FileName.c_str(), &st) != 0) {
return false;
}
@@ -463,9 +461,7 @@ unsigned int FileInfo::size() const
}
#elif defined(FC_OS_LINUX) || defined(FC_OS_CYGWIN) || defined(FC_OS_MACOSX) || defined(FC_OS_BSD)
struct stat st
{
};
struct stat st {};
if (stat(FileName.c_str(), &st) == 0) {
bytes = st.st_size;
}
@@ -487,9 +483,7 @@ TimeInfo FileInfo::lastModified() const
}
#elif defined(FC_OS_LINUX) || defined(FC_OS_CYGWIN) || defined(FC_OS_MACOSX) || defined(FC_OS_BSD)
struct stat st
{
};
struct stat st {};
if (stat(FileName.c_str(), &st) == 0) {
ti.setTime_t(st.st_mtime);
}
@@ -511,9 +505,7 @@ TimeInfo FileInfo::lastRead() const
}
#elif defined(FC_OS_LINUX) || defined(FC_OS_CYGWIN) || defined(FC_OS_MACOSX) || defined(FC_OS_BSD)
struct stat st
{
};
struct stat st {};
if (stat(FileName.c_str(), &st) == 0) {
ti.setTime_t(st.st_atime);
}
+17
View File
@@ -22,6 +22,8 @@
#include "PreCompiled.h"
#include <fmt/format.h>
#include "Placement.h"
#include "Matrix.h"
#include "Rotation.h"
@@ -209,3 +211,18 @@ Placement Placement::sclerp(const Placement& p0, const Placement& p1, double t,
Placement trf = p0.inverse() * p1;
return p0 * trf.pow(t, shorten);
}
std::string Placement::toString() const
{
Base::Vector3d pos = getPosition();
Base::Rotation rot = getRotation();
Base::Vector3d axis;
double angle {};
rot.getRawValue(axis, angle);
// clang-format off
return fmt::format("position ({:.1f}, {:.1f}, {:.1f}), axis ({:.1f}, {:.1f}, {:.1f}), angle {:.1f}\n",
pos.x, pos.y, pos.z, axis.x, axis.y, axis.z, angle);
// clang-format on
}
+5
View File
@@ -23,6 +23,8 @@
#ifndef BASE_PLACEMENT_H
#define BASE_PLACEMENT_H
#include <string>
#include "Rotation.h"
#include "Vector3D.h"
@@ -105,6 +107,9 @@ public:
static Placement
sclerp(const Placement& p0, const Placement& p1, double t, bool shorten = true);
/// Returns string representation of the placement, useful for debugging
std::string toString() const;
private:
Vector3<double> _pos;
Base::Rotation _rot;
+18 -19
View File
@@ -22,17 +22,17 @@
#include "PreCompiled.h"
#ifndef _PreComp_
#ifdef FC_OS_WIN32
#define _USE_MATH_DEFINES
#endif // FC_OS_WIN32
#include <cmath>
#include <array>
#endif
#include <fmt/format.h>
#include <Base/Tools.h>
#include "Quantity.h"
#include "Exception.h"
#include "Quantity.h"
#include "UnitsApi.h"
#include <boost/math/special_functions/fpclassify.hpp>
/** \defgroup Units Units system
\ingroup BASE
@@ -81,10 +81,10 @@ Quantity::Quantity(double value, const Unit& unit)
, myUnit {unit}
{}
Quantity::Quantity(double value, const QString& unit)
Quantity::Quantity(double value, const std::string& unit)
: myValue {0.0}
{
if (unit.isEmpty()) {
if (unit.empty()) {
this->myValue = value;
this->myUnit = Unit();
return;
@@ -236,29 +236,28 @@ Quantity Quantity::operator-() const
return Quantity(-(this->myValue), this->myUnit);
}
QString Quantity::getUserString(double& factor, QString& unitString) const
std::string Quantity::getUserString(double& factor, std::string& unitString) const
{
return Base::UnitsApi::schemaTranslate(*this, factor, unitString);
}
QString Quantity::getUserString(UnitsSchema* schema, double& factor, QString& unitString) const
std::string
Quantity::getUserString(UnitsSchema* schema, double& factor, std::string& unitString) const
{
return schema->schemaTranslate(*this, factor, unitString);
}
QString Quantity::getSafeUserString() const
std::string Quantity::getSafeUserString() const
{
auto retString = getUserString();
if (Q_LIKELY(this->myValue != 0)) {
auto feedbackQty = parse(retString);
auto ret = getUserString();
if (this->myValue) {
auto feedbackQty = parse(ret);
auto feedbackVal = feedbackQty.getValue();
if (feedbackVal == 0) {
retString = QStringLiteral("%1 %2").arg(this->myValue).arg(this->getUnit().getString());
ret = fmt::format("{} {}", this->myValue, this->getUnit().getString());
}
}
retString =
QString::fromStdString(Base::Tools::escapeQuotesFromString(retString.toStdString()));
return retString;
return Base::Tools::escapeQuotesFromString(ret);
}
/// true if it has a number without a unit
@@ -282,7 +281,7 @@ bool Quantity::isQuantity() const
// true if it has a number with or without a unit
bool Quantity::isValid() const
{
return !boost::math::isnan(myValue);
return !std::isnan(myValue);
}
void Quantity::setInvalid()
@@ -562,11 +561,11 @@ private:
#pragma GCC diagnostic pop
#endif
Quantity Quantity::parse(const QString& string)
Quantity Quantity::parse(const std::string& string)
{
// parse from buffer
QuantityParser::YY_BUFFER_STATE my_string_buffer =
QuantityParser::yy_scan_string(string.toUtf8().data());
QuantityParser::yy_scan_string(string.c_str());
QuantityParser::StringBufferCleaner cleaner(my_string_buffer);
// set the global return variables
QuantResult = Quantity(DOUBLE_MIN);
+8 -8
View File
@@ -25,7 +25,7 @@
#define BASE_Quantity_H
#include "Unit.h"
#include <QString>
#include <string>
// NOLINTBEGIN
#ifndef DOUBLE_MAX
@@ -130,7 +130,7 @@ public:
Quantity(const Quantity&) = default;
Quantity(Quantity&&) = default;
explicit Quantity(double value, const Unit& unit = Unit());
explicit Quantity(double value, const QString& unit);
explicit Quantity(double value, const std::string& unit);
/// Destruction
~Quantity() = default;
@@ -166,17 +166,17 @@ public:
myFormat = fmt;
}
/// transfer to user preferred unit/potence
QString getUserString(double& factor, QString& unitString) const;
QString getUserString() const
std::string getUserString(double& factor, std::string& unitString) const;
std::string getUserString() const
{ // to satisfy GCC
double dummy1 {};
QString dummy2 {};
std::string dummy2 {};
return getUserString(dummy1, dummy2);
}
QString getUserString(UnitsSchema* schema, double& factor, QString& unitString) const;
QString getSafeUserString() const;
std::string getUserString(UnitsSchema* schema, double& factor, std::string& unitString) const;
std::string getSafeUserString() const;
static Quantity parse(const QString& string);
static Quantity parse(const std::string& string);
/// returns the unit of the quantity
const Unit& getUnit() const
+12 -12
View File
@@ -42,7 +42,7 @@ std::string QuantityPy::representation() const
Py::Float flt(val);
ret << static_cast<std::string>(flt.repr());
if (!unit.isEmpty()) {
ret << " " << unit.getString().toUtf8().constData();
ret << " " << unit.getString();
}
return ret.str();
@@ -63,7 +63,7 @@ PyObject* QuantityPy::toStr(PyObject* args)
ret.setf(std::ios::fixed, std::ios::floatfield);
ret << val;
if (!unit.isEmpty()) {
ret << " " << unit.getString().toUtf8().constData();
ret << " " << unit.getString();
}
return Py_BuildValue("s", ret.str().c_str());
@@ -127,10 +127,10 @@ int QuantityPy::PyInit(PyObject* args, PyObject* /*kwd*/)
PyErr_Clear(); // set by PyArg_ParseTuple()
char* string {};
if (PyArg_ParseTuple(args, "et", "utf-8", &string)) {
QString qstr = QString::fromUtf8(string);
std::string str(string);
PyMem_Free(string);
try {
*self = Quantity::parse(qstr);
*self = Quantity::parse(str);
}
catch (const Base::ParserError& e) {
PyErr_SetString(PyExc_ValueError, e.what());
@@ -142,7 +142,7 @@ int QuantityPy::PyInit(PyObject* args, PyObject* /*kwd*/)
PyErr_Clear(); // set by PyArg_ParseTuple()
if (PyArg_ParseTuple(args, "det", &f, "utf-8", &string)) {
QString unit = QString::fromUtf8(string);
std::string unit(string);
PyMem_Free(string);
try {
*self = Quantity(f, unit);
@@ -161,15 +161,15 @@ int QuantityPy::PyInit(PyObject* args, PyObject* /*kwd*/)
PyObject* QuantityPy::getUserPreferred(PyObject* /*args*/)
{
QString uus;
std::string uus;
double factor {};
Py::Tuple res(3);
QString uss = getQuantityPtr()->getUserString(factor, uus);
auto uss = getQuantityPtr()->getUserString(factor, uus);
res[0] = Py::String(uss.toUtf8(), "utf-8");
res[0] = Py::String(uss, "utf-8");
res[1] = Py::Float(factor);
res[2] = Py::String(uus.toUtf8(), "utf-8");
res[2] = Py::String(uus, "utf-8");
return Py::new_reference_to(res);
}
@@ -236,9 +236,9 @@ PyObject* QuantityPy::getValueAs(PyObject* args)
PyErr_Clear();
char* string {};
if (PyArg_ParseTuple(args, "et", "utf-8", &string)) {
QString qstr = QString::fromUtf8(string);
std::string str(string);
PyMem_Free(string);
quant = Quantity::parse(qstr);
quant = Quantity::parse(str);
}
}
@@ -633,7 +633,7 @@ void QuantityPy::setUnit(Py::Object arg)
Py::String QuantityPy::getUserString() const
{
return {getQuantityPtr()->getUserString().toUtf8(), "utf-8"};
return {getQuantityPtr()->getUserString(), "utf-8"};
}
Py::Dict QuantityPy::getFormat() const
+33
View File
@@ -0,0 +1,33 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/****************************************************************************
* *
* Copyright (c) 2024 Kacper Donat <kacper@kadet.net> *
* *
* 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/>. *
* *
***************************************************************************/
#include "PreCompiled.h"
#include "ServiceProvider.h"
Base::ServiceProvider& Base::ServiceProvider::get()
{
static Base::ServiceProvider instance;
return instance;
}
+143
View File
@@ -0,0 +1,143 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/****************************************************************************
* *
* Copyright (c) 2024 Kacper Donat <kacper@kadet.net> *
* *
* 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/>. *
* *
***************************************************************************/
#ifndef APP_SERVICE_PROVIDER_H
#define APP_SERVICE_PROVIDER_H
#include <FCGlobal.h>
#include <algorithm>
#include <deque>
#include <map>
#include <string>
#include <any>
#include <list>
namespace Base
{
class BaseExport ServiceProvider
{
struct ServiceDescriptor
{
std::string name;
std::any instance;
template<typename T>
T* get() const
{
return std::any_cast<T*>(instance);
}
};
public:
ServiceProvider() = default;
/**
* Returns most recent implementation of service specified as T param.
*
* @tparam T Service interface
*/
template<typename T>
T* provide() const
{
if (auto it = _implementations.find(typeid(T).name()); it != _implementations.end()) {
auto descriptors = it->second;
if (descriptors.empty()) {
return nullptr;
}
return descriptors.front().get<T>();
}
return nullptr;
}
/**
* Returns all implementations of service specified as T param.
*
* @tparam T Service interface
*/
template<typename T>
std::list<T*> all() const
{
if (auto it = _implementations.find(typeid(T).name()); it != _implementations.end()) {
auto source = it->second;
std::list<T*> result(source.size());
std::transform(source.begin(),
source.end(),
result.begin(),
[](const ServiceDescriptor& descriptor) {
return descriptor.get<T>();
});
return result;
}
return {};
}
/**
* Adds new implementation of service T.
*
* @tparam T Service interface
*/
template<typename T>
void implement(T* contract)
{
ServiceDescriptor descriptor {typeid(T).name(), contract};
_implementations[typeid(T).name()].push_front(descriptor);
}
static ServiceProvider& get();
private:
std::map<const char*, std::deque<ServiceDescriptor>> _implementations;
};
template<typename T>
T* provideImplementation()
{
return ServiceProvider::get().provide<T>();
}
template<typename T>
std::list<T*> provideAllImplementations()
{
return ServiceProvider::get().all<T>();
}
template<typename T>
void implementContract(T* implementation)
{
ServiceProvider::get().implement<T>(implementation);
}
} // namespace Base
#endif // APP_SERVICE_PROVIDER_H
+410 -383
View File
File diff suppressed because it is too large Load Diff
+17 -34
View File
@@ -25,35 +25,12 @@
#define BASE_Unit_H
#include <cstdint>
#include <QString>
#include <string>
#include <FCGlobal.h>
namespace Base
{
#define UnitSignatureLengthBits 4
#define UnitSignatureMassBits 4
#define UnitSignatureTimeBits 4
#define UnitSignatureElectricCurrentBits 4
#define UnitSignatureThermodynamicTemperatureBits 4
#define UnitSignatureAmountOfSubstanceBits 4
#define UnitSignatureLuminousIntensityBits 4
#define UnitSignatureAngleBits 4
// Hint:
// https://en.cppreference.com/w/cpp/language/bit_field
// https://stackoverflow.com/questions/33723631/signed-bit-field-in-c14
struct UnitSignature
{
int32_t Length: UnitSignatureLengthBits;
int32_t Mass: UnitSignatureMassBits;
int32_t Time: UnitSignatureTimeBits;
int32_t ElectricCurrent: UnitSignatureElectricCurrentBits;
int32_t ThermodynamicTemperature: UnitSignatureThermodynamicTemperatureBits;
int32_t AmountOfSubstance: UnitSignatureAmountOfSubstanceBits;
int32_t LuminousIntensity: UnitSignatureLuminousIntensityBits;
int32_t Angle: UnitSignatureAngleBits;
};
/**
* The Unit class.
*/
@@ -72,15 +49,15 @@ public:
Unit();
Unit(const Unit&) = default;
Unit(Unit&&) = default;
explicit Unit(const QString& expr);
explicit Unit(const std::string& expr);
/// Destruction
~Unit() = default;
/** Operators. */
//@{
inline Unit& operator*=(const Unit& that);
inline Unit& operator/=(const Unit& that);
int operator[](int index) const;
Unit operator*(const Unit&) const;
Unit operator/(const Unit&) const;
bool operator==(const Unit&) const;
@@ -91,17 +68,22 @@ public:
Unit& operator=(const Unit&) = default;
Unit& operator=(Unit&&) = default;
Unit pow(double exp) const;
Unit sqrt() const;
Unit cbrt() const;
//@}
/// get the unit signature
const UnitSignature& getSignature() const
{
return Sig;
}
int length() const;
int mass() const;
int time() const;
int electricCurrent() const;
int thermodynamicTemperature() const;
int amountOfSubstance() const;
int luminousIntensity() const;
int angle() const;
bool isEmpty() const;
QString getString() const;
std::string getString() const;
/// get the type as an string such as "Area", "Length" or "Pressure".
QString getTypeString() const;
std::string getTypeString() const;
/** Predefined Unit types. */
//@{
@@ -137,6 +119,7 @@ public:
static const Unit ElectricalConductance;
static const Unit ElectricalResistance;
static const Unit ElectricalConductivity;
static const Unit ElectromagneticPotential;
static const Unit AmountOfSubstance;
static const Unit LuminousIntensity;
@@ -176,7 +159,7 @@ public:
//@}
private:
UnitSignature Sig;
uint32_t Val;
};
inline Unit& Unit::operator*=(const Unit& that)
+22 -25
View File
@@ -34,23 +34,24 @@ using namespace Base;
// returns a string which represents the object e.g. when printed in python
std::string UnitPy::representation() const
{
const UnitSignature& Sig = getUnitPtr()->getSignature();
std::stringstream ret;
Unit* self = getUnitPtr();
ret << "Unit: ";
ret << getUnitPtr()->getString().toUtf8().constData() << " (";
ret << Sig.Length << ",";
ret << Sig.Mass << ",";
ret << Sig.Time << ",";
ret << Sig.ElectricCurrent << ",";
ret << Sig.ThermodynamicTemperature << ",";
ret << Sig.AmountOfSubstance << ",";
ret << Sig.LuminousIntensity << ",";
ret << Sig.Angle << ")";
std::string type = getUnitPtr()->getTypeString().toUtf8().constData();
ret << self->getString() << " (";
ret << (*self).length() << ",";
ret << (*self).mass() << ",";
ret << (*self).time() << ",";
ret << (*self).electricCurrent() << ",";
ret << (*self).thermodynamicTemperature() << ",";
ret << (*self).amountOfSubstance() << ",";
ret << (*self).luminousIntensity() << ",";
ret << (*self).angle() << ")";
std::string type = self->getTypeString();
if (!type.empty()) {
ret << " [" << type << "]";
}
return ret.str();
}
@@ -83,10 +84,10 @@ int UnitPy::PyInit(PyObject* args, PyObject* /*kwd*/)
// get string
char* string {};
if (PyArg_ParseTuple(args, "et", "utf-8", &string)) {
QString qstr = QString::fromUtf8(string);
std::string str(string);
PyMem_Free(string);
try {
*self = Quantity::parse(qstr).getUnit();
*self = Quantity::parse(str).getUnit();
return 0;
}
catch (const Base::ParserError& e) {
@@ -206,25 +207,21 @@ PyObject* UnitPy::richCompare(PyObject* v, PyObject* w, int op)
Py::String UnitPy::getType() const
{
return {getUnitPtr()->getTypeString().toUtf8(), "utf-8"};
return {getUnitPtr()->getTypeString(), "utf-8"};
}
Py::Tuple UnitPy::getSignature() const
{
const UnitSignature& Sig = getUnitPtr()->getSignature();
Py::Tuple tuple(8);
tuple.setItem(0, Py::Long(Sig.Length));
tuple.setItem(1, Py::Long(Sig.Mass));
tuple.setItem(2, Py::Long(Sig.Time));
tuple.setItem(3, Py::Long(Sig.ElectricCurrent));
tuple.setItem(4, Py::Long(Sig.ThermodynamicTemperature));
tuple.setItem(5, Py::Long(Sig.AmountOfSubstance));
tuple.setItem(6, Py::Long(Sig.LuminousIntensity));
tuple.setItem(7, Py::Long(Sig.Angle));
Unit* self = getUnitPtr();
for (auto i = 0; i < tuple.size(); i++) {
tuple.setItem(i, Py::Long((*self)[i]));
}
return tuple;
}
PyObject* UnitPy::getCustomAttributes(const char* /*attr*/) const
{
return nullptr;
+29 -29
View File
@@ -22,12 +22,14 @@
#include "PreCompiled.h"
#ifdef __GNUC__
#include <unistd.h>
#endif
#include <iostream>
#include <iomanip>
#include <locale>
#include <memory>
#include <CXX/WrapPython.h>
#include <memory>
#include <fmt/format.h>
#include <QString>
#include "Exception.h"
@@ -40,19 +42,6 @@
#include "UnitsSchemaFemMilliMeterNewton.h"
#include "UnitsSchemaMeterDecimal.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#ifndef M_E
#define M_E 2.71828182845904523536
#endif
#ifndef DOUBLE_MAX
#define DOUBLE_MAX 1.7976931348623157E+308 /* max decimal value of a "double"*/
#endif
#ifndef DOUBLE_MIN
#define DOUBLE_MIN 2.2250738585072014E-308 /* min decimal value of a "double"*/
#endif
using namespace Base;
// === static attributes ================================================
@@ -139,23 +128,33 @@ void UnitsApi::setSchema(UnitSystem system)
// Quantity (e.g. mi=1.8km rather then 1.6km).
}
QString UnitsApi::toString(const Base::Quantity& quantity, const QuantityFormat& format)
std::string UnitsApi::toString(const Base::Quantity& quantity, const QuantityFormat& format)
{
QString value = QString::fromLatin1("'%1 %2'")
.arg(quantity.getValue(), 0, format.toFormat(), format.precision)
.arg(quantity.getUnit().getString());
return value;
return fmt::format("'{} {}'", toNumber(quantity, format), quantity.getUnit().getString());
}
QString UnitsApi::toNumber(const Base::Quantity& quantity, const QuantityFormat& format)
std::string UnitsApi::toNumber(const Base::Quantity& quantity, const QuantityFormat& format)
{
return toNumber(quantity.getValue(), format);
}
QString UnitsApi::toNumber(double value, const QuantityFormat& format)
std::string UnitsApi::toNumber(double value, const QuantityFormat& format)
{
QString number = QString::fromLatin1("%1").arg(value, 0, format.toFormat(), format.precision);
return number;
std::stringstream ss;
switch (format.format) {
case QuantityFormat::Fixed:
ss << std::fixed;
break;
case QuantityFormat::Scientific:
ss << std::scientific;
break;
default:
break;
}
ss << std::setprecision(format.precision) << value;
return ss.str();
}
// return true if the current user schema uses multiple units for length (ex. Ft/In)
@@ -177,7 +176,8 @@ std::string UnitsApi::getBasicLengthUnit()
// === static translation methods ==========================================
QString UnitsApi::schemaTranslate(const Base::Quantity& quant, double& factor, QString& unitString)
std::string
UnitsApi::schemaTranslate(const Base::Quantity& quant, double& factor, std::string& unitString)
{
return UserPrefSystem->schemaTranslate(quant, factor, unitString);
}
@@ -185,7 +185,7 @@ QString UnitsApi::schemaTranslate(const Base::Quantity& quant, double& factor, Q
double UnitsApi::toDouble(PyObject* args, const Base::Unit& u)
{
if (PyUnicode_Check(args)) {
QString str = QString::fromUtf8(PyUnicode_AsUTF8(args));
std::string str(PyUnicode_AsUTF8(args));
// Parse the string
Quantity q = Quantity::parse(str);
if (q.getUnit() == u) {
@@ -208,7 +208,7 @@ Quantity UnitsApi::toQuantity(PyObject* args, const Base::Unit& u)
{
double d {};
if (PyUnicode_Check(args)) {
QString str = QString::fromUtf8(PyUnicode_AsUTF8(args));
std::string str(PyUnicode_AsUTF8(args));
// Parse the string
Quantity q = Quantity::parse(str);
d = q.getValue();
+10 -10
View File
@@ -60,12 +60,12 @@ public:
/// Returns a brief description of a schema
static QString getDescription(UnitSystem);
static QString
schemaTranslate(const Base::Quantity& quant, double& factor, QString& unitString);
static QString schemaTranslate(const Base::Quantity& quant)
static std::string
schemaTranslate(const Base::Quantity& quant, double& factor, std::string& unitString);
static std::string schemaTranslate(const Base::Quantity& quant)
{ // to satisfy GCC
double dummy1 {};
QString dummy2;
std::string dummy2;
return UnitsApi::schemaTranslate(quant, dummy1, dummy2);
}
@@ -73,22 +73,22 @@ public:
* The string is a number in C locale (i.e. the decimal separator is always a dot) and if
* needed represented in scientific notation. The string also includes the unit of the quantity.
*/
static QString toString(const Base::Quantity& q,
const QuantityFormat& f = QuantityFormat(QuantityFormat::Default));
static std::string toString(const Base::Quantity& q,
const QuantityFormat& f = QuantityFormat(QuantityFormat::Default));
/** Get a number as string for a quantity of a given format.
* The string is a number in C locale (i.e. the decimal separator is always a dot) and if
* needed represented in scientific notation. The string doesn't include the unit of the
* quantity.
*/
static QString toNumber(const Base::Quantity& q,
const QuantityFormat& f = QuantityFormat(QuantityFormat::Default));
static std::string toNumber(const Base::Quantity& q,
const QuantityFormat& f = QuantityFormat(QuantityFormat::Default));
/** Get a number as string for a double of a given format.
* The string is a number in C locale (i.e. the decimal separator is always a dot) and if
* needed represented in scientific notation. The string doesn't include the unit of the
* quantity.
*/
static QString toNumber(double value,
const QuantityFormat& f = QuantityFormat(QuantityFormat::Default));
static std::string toNumber(double value,
const QuantityFormat& f = QuantityFormat(QuantityFormat::Default));
/// generate a value for a quantity with default user preferred system
static double toDouble(PyObject* args, const Base::Unit& u = Base::Unit());
+7 -8
View File
@@ -87,10 +87,10 @@ PyObject* UnitsApi::sParseQuantity(PyObject* /*self*/, PyObject* args)
}
Quantity rtn;
QString qstr = QString::fromUtf8(pstr);
std::string str(pstr);
PyMem_Free(pstr);
try {
rtn = Quantity::parse(qstr);
rtn = Quantity::parse(str);
}
catch (const Base::ParserError&) {
PyErr_Format(PyExc_ValueError, "invalid unit expression \n");
@@ -174,13 +174,13 @@ PyObject* UnitsApi::sSchemaTranslate(PyObject* /*self*/, PyObject* args)
}
double factor {};
QString uus;
QString uss = schema->schemaTranslate(quant, factor, uus);
std::string uus;
std::string uss = schema->schemaTranslate(quant, factor, uus);
Py::Tuple res(3);
res[0] = Py::String(uss.toUtf8(), "utf-8");
res[0] = Py::String(uss, "utf-8");
res[1] = Py::Float(factor);
res[2] = Py::String(uus.toUtf8(), "utf-8");
res[2] = Py::String(uus, "utf-8");
return Py::new_reference_to(res);
}
@@ -221,6 +221,5 @@ PyObject* UnitsApi::sToNumber(PyObject* /*self*/, PyObject* args)
return nullptr;
}
QString string = toNumber(value, qf);
return Py::new_reference_to(Py::String(string.toStdString()));
return Py::new_reference_to(Py::String(toNumber(value, qf)));
}
+6 -5
View File
@@ -20,7 +20,6 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#ifdef __GNUC__
#include <unistd.h>
@@ -31,11 +30,11 @@
#include "UnitsSchema.h"
using namespace Base;
QString
UnitsSchema::toLocale(const Base::Quantity& quant, double factor, const QString& unitString) const
std::string UnitsSchema::toLocale(const Base::Quantity& quant,
double factor,
const std::string& unitString) const
{
QLocale Lc;
const QuantityFormat& format = quant.getFormat();
@@ -45,5 +44,7 @@ UnitsSchema::toLocale(const Base::Quantity& quant, double factor, const QString&
}
QString Ln = Lc.toString((quant.getValue() / factor), format.toFormat(), format.precision);
return QString::fromUtf8("%1 %2").arg(Ln, unitString);
return QString::fromStdString("%1 %2")
.arg(Ln, QString::fromStdString(unitString))
.toStdString();
}
+5 -8
View File
@@ -20,14 +20,12 @@
* *
***************************************************************************/
#ifndef BASE_UNITSSCHEMA_H
#define BASE_UNITSSCHEMA_H
#include <QString>
#include <string>
#include <Base/Quantity.h>
namespace Base
{
@@ -73,10 +71,11 @@ public:
{}
/// This method translates the quantity in a string as the user may expect it.
virtual QString
schemaTranslate(const Base::Quantity& quant, double& factor, QString& unitString) = 0;
virtual std::string
schemaTranslate(const Base::Quantity& quant, double& factor, std::string& unitString) = 0;
QString toLocale(const Base::Quantity& quant, double factor, const QString& unitString) const;
std::string
toLocale(const Base::Quantity& quant, double factor, const std::string& unitString) const;
// return true if this schema uses multiple units for length (ex. Ft/In)
virtual bool isMultiUnitLength() const
@@ -97,8 +96,6 @@ public:
}
};
} // namespace Base
#endif // BASE_UNITSSCHEMA_H
+25 -41
View File
@@ -22,56 +22,40 @@
#include "PreCompiled.h"
#ifdef __GNUC__
#include <unistd.h>
#ifndef _PreComp_
#include <algorithm>
#include <array>
#include <utility>
#endif
#include <QString>
#include "UnitsSchemaCentimeters.h"
using namespace Base;
QString UnitsSchemaCentimeters::schemaTranslate(const Base::Quantity& quant,
double& factor,
QString& unitString)
std::string UnitsSchemaCentimeters::schemaTranslate(const Base::Quantity& quant,
double& factor,
std::string& unitString)
{
Unit unit = quant.getUnit();
if (unit == Unit::Length) {
// all length units in centimeters
unitString = QString::fromLatin1("cm");
factor = 10.0;
}
else if (unit == Unit::Area) {
// all area units in square meters
unitString = QString::fromLatin1("m^2");
factor = 1000000.0;
}
else if (unit == Unit::Volume) {
// all area units in cubic meters
unitString = QString::fromLatin1("m^3");
factor = 1000000000.0;
}
else if (unit == Unit::Power) {
unitString = QString::fromLatin1("W");
factor = 1000000;
}
else if (unit == Unit::ElectricPotential) {
unitString = QString::fromLatin1("V");
factor = 1000000;
}
else if (unit == Unit::HeatFlux) {
unitString = QString::fromLatin1("W/m^2");
factor = 1.0;
}
else if (unit == Unit::Velocity) {
unitString = QString::fromLatin1("mm/min");
factor = 1.0 / 60;
static std::array<std::pair<Unit, std::pair<std::string, double>>, 7> unitSpecs {{
{Unit::Length, {"cm", 10.0}},
{Unit::Area, {"m^2", 1000000.0}},
{Unit::Volume, {"m^3", 1000000000.0}},
{Unit::Power, {"W", 1000000.0}},
{Unit::ElectricPotential, {"V", 1000000.0}},
{Unit::HeatFlux, {"W/m^2", 1.0}},
{Unit::Velocity, {"mm/min", 1.0 / 60}},
}};
const auto unit = quant.getUnit();
const auto spec = std::find_if(unitSpecs.begin(), unitSpecs.end(), [&](const auto& pair) {
return pair.first == unit;
});
if (spec != std::end(unitSpecs)) {
unitString = spec->second.first;
factor = spec->second.second;
}
else {
// default action for all cases without special treatment:
unitString = quant.getUnit().getString();
factor = 1.0;
}
+2 -5
View File
@@ -20,14 +20,11 @@
* *
***************************************************************************/
#ifndef BASE_UNITSSCHEMACENTIMETERS_H
#define BASE_UNITSSCHEMACENTIMETERS_H
#include <QString>
#include "UnitsSchema.h"
namespace Base
{
@@ -37,8 +34,8 @@ namespace Base
class UnitsSchemaCentimeters: public UnitsSchema
{
public:
QString
schemaTranslate(const Base::Quantity& quant, double& factor, QString& unitString) override;
std::string
schemaTranslate(const Base::Quantity& quant, double& factor, std::string& unitString) override;
std::string getBasicLengthUnit() const override
{
+21 -20
View File
@@ -23,37 +23,38 @@
#include "PreCompiled.h"
#ifdef __GNUC__
#include <unistd.h>
#ifndef _PreComp_
#include <algorithm>
#include <array>
#include <utility>
#endif
#include <QString>
#include "UnitsSchemaFemMilliMeterNewton.h"
using namespace Base;
QString UnitsSchemaFemMilliMeterNewton::schemaTranslate(const Quantity& quant,
double& factor,
QString& unitString)
std::string UnitsSchemaFemMilliMeterNewton::schemaTranslate(const Quantity& quant,
double& factor,
std::string& unitString)
{
Unit unit = quant.getUnit();
if (unit == Unit::Length) {
// all length units in millimeters
unitString = QString::fromLatin1("mm");
factor = 1.0;
}
else if (unit == Unit::Mass) {
// all mass units in t
unitString = QString::fromUtf8("t");
factor = 1e3;
static std::array<std::pair<Unit, std::pair<std::string, double>>, 2> unitSpecs {{
{Unit::Length, {"mm", 1.0}},
{Unit::Mass, {"t", 1e3}},
}};
const auto unit = quant.getUnit();
const auto spec = std::find_if(unitSpecs.begin(), unitSpecs.end(), [&](const auto& pair) {
return pair.first == unit;
});
if (spec != std::end(unitSpecs)) {
unitString = spec->second.first;
factor = spec->second.second;
}
else {
// default action for all cases without special treatment:
unitString = quant.getUnit().getString();
factor = 1.0;
}
return toLocale(quant, factor, unitString);
}
+2 -8
View File
@@ -21,18 +21,14 @@
* *
***************************************************************************/
#ifndef BASE_UNITSSCHEMAFEMMLLIMETERNEWTON_H
#define BASE_UNITSSCHEMAFEMMLLIMETERNEWTON_H
#include <QString>
#include "UnitsSchema.h"
namespace Base
{
/* Milli metric / Newton / Seconds unit schema for use in FEM.
* Lengths are always in mm.
* Mass is in t.
@@ -42,12 +38,10 @@ namespace Base
class UnitsSchemaFemMilliMeterNewton: public UnitsSchema
{
public:
QString
schemaTranslate(const Base::Quantity& quant, double& factor, QString& unitString) override;
std::string
schemaTranslate(const Base::Quantity& quant, double& factor, std::string& unitString) override;
};
} // namespace Base
#endif // BASE_UNITSSCHEMAFEMMLLIMETERNEWTON_H
+62 -67
View File
@@ -30,16 +30,13 @@
#include <unistd.h>
#endif
#include <QString>
#include "UnitsSchemaImperial1.h"
using namespace Base;
QString
UnitsSchemaImperial1::schemaTranslate(const Quantity& quant, double& factor, QString& unitString)
std::string UnitsSchemaImperial1::schemaTranslate(const Quantity& quant,
double& factor,
std::string& unitString)
{
double UnitValue = std::abs(quant.getValue());
Unit unit = quant.getUnit();
@@ -49,76 +46,76 @@ UnitsSchemaImperial1::schemaTranslate(const Quantity& quant, double& factor, QSt
// now do special treatment on all cases seems necessary:
if (unit == Unit::Length) { // Length handling ============================
if (UnitValue < 0.00000254) { // smaller then 0.001 thou -> inch and scientific notation
unitString = QString::fromLatin1("in");
unitString = "in";
factor = 25.4;
}
else if (UnitValue < 2.54) { // smaller then 0.1 inch -> Thou (mil)
unitString = QString::fromLatin1("thou");
unitString = "thou";
factor = 0.0254;
}
else if (UnitValue < 304.8) {
unitString = QString::fromLatin1("\"");
unitString = "\"";
factor = 25.4;
}
else if (UnitValue < 914.4) {
unitString = QString::fromLatin1("\'");
unitString = "\'";
factor = 304.8;
}
else if (UnitValue < 1609344.0) {
unitString = QString::fromLatin1("yd");
unitString = "yd";
factor = 914.4;
}
else if (UnitValue < 1609344000.0) {
unitString = QString::fromLatin1("mi");
unitString = "mi";
factor = 1609344.0;
}
else { // bigger then 1000 mi -> scientific notation
unitString = QString::fromLatin1("in");
unitString = "in";
factor = 25.4;
}
}
else if (unit == Unit::Angle) {
unitString = QString::fromUtf8("\xC2\xB0");
unitString = "\xC2\xB0";
factor = 1.0;
}
else if (unit == Unit::Area) {
// TODO: Cascade for the Areas
// default action for all cases without special treatment:
unitString = QString::fromLatin1("in^2");
unitString = "in^2";
factor = 645.16;
}
else if (unit == Unit::Volume) {
// TODO: Cascade for the Volume
// default action for all cases without special treatment:
unitString = QString::fromLatin1("in^3");
unitString = "in^3";
factor = 16387.064;
}
else if (unit == Unit::Mass) {
// TODO: Cascade for the weights
// default action for all cases without special treatment:
unitString = QString::fromLatin1("lb");
unitString = "lb";
factor = 0.45359237;
}
else if (unit == Unit::Pressure) {
if (UnitValue < 6894.744) { // psi is the smallest
unitString = QString::fromLatin1("psi");
unitString = "psi";
factor = 6.894744825494;
}
else if (UnitValue < 6894744.825) {
unitString = QString::fromLatin1("ksi");
unitString = "ksi";
factor = 6894.744825494;
}
else { // bigger then 1000 ksi -> psi + scientific notation
unitString = QString::fromLatin1("psi");
unitString = "psi";
factor = 6.894744825494;
}
}
else if (unit == Unit::Stiffness) { // Conversion to lbf/in
unitString = QString::fromLatin1("lbf/in");
unitString = "lbf/in";
factor = 4.448222 / 0.0254;
}
else if (unit == Unit::Velocity) {
unitString = QString::fromLatin1("in/min");
unitString = "in/min";
factor = 25.4 / 60;
}
else {
@@ -130,56 +127,55 @@ UnitsSchemaImperial1::schemaTranslate(const Quantity& quant, double& factor, QSt
return toLocale(quant, factor, unitString);
}
QString UnitsSchemaImperialDecimal::schemaTranslate(const Base::Quantity& quant,
double& factor,
QString& unitString)
std::string UnitsSchemaImperialDecimal::schemaTranslate(const Base::Quantity& quant,
double& factor,
std::string& unitString)
{
// double UnitValue = std::abs(quant.getValue());
Unit unit = quant.getUnit();
// for imperial user/programmer mind; UnitValue is in internal system, that means
// mm/kg/s. And all combined units have to be calculated from there!
// now do special treatment on all cases seems necessary:
if (unit == Unit::Length) { // Length handling ============================
unitString = QString::fromLatin1("in");
unitString = "in";
factor = 25.4;
}
else if (unit == Unit::Angle) {
unitString = QString::fromUtf8("\xC2\xB0");
unitString = "\xC2\xB0";
factor = 1.0;
}
else if (unit == Unit::Area) {
// TODO: Cascade for the Areas
// default action for all cases without special treatment:
unitString = QString::fromLatin1("in^2");
unitString = "in^2";
factor = 645.16;
}
else if (unit == Unit::Volume) {
// TODO: Cascade for the Volume
// default action for all cases without special treatment:
unitString = QString::fromLatin1("in^3");
unitString = "in^3";
factor = 16387.064;
}
else if (unit == Unit::Mass) {
// TODO: Cascade for the weights
// default action for all cases without special treatment:
unitString = QString::fromLatin1("lb");
unitString = "lb";
factor = 0.45359237;
}
else if (unit == Unit::Pressure) {
unitString = QString::fromLatin1("psi");
unitString = "psi";
factor = 6.894744825494;
}
else if (unit == Unit::Stiffness) {
unitString = QString::fromLatin1("lbf/in");
unitString = "lbf/in";
factor = 4.448222 / 0.0254;
}
else if (unit == Unit::Velocity) {
unitString = QString::fromLatin1("in/min");
unitString = "in/min";
factor = 25.4 / 60;
}
else if (unit == Unit::Acceleration) {
unitString = QString::fromLatin1("in/min^2");
unitString = "in/min^2";
factor = 25.4 / 3600;
}
else {
@@ -191,15 +187,15 @@ QString UnitsSchemaImperialDecimal::schemaTranslate(const Base::Quantity& quant,
return toLocale(quant, factor, unitString);
}
QString UnitsSchemaImperialBuilding::schemaTranslate(const Quantity& quant,
double& factor,
QString& unitString)
std::string UnitsSchemaImperialBuilding::schemaTranslate(const Quantity& quant,
double& factor,
std::string& unitString)
{
// this schema expresses distances in feet + inches + fractions
// ex: 3'- 4 1/4" with proper rounding
Unit unit = quant.getUnit();
if (unit == Unit::Length) {
unitString = QString::fromLatin1("in");
unitString = "in";
factor = 25.4;
// Total number of inches to format
@@ -227,7 +223,7 @@ QString UnitsSchemaImperialBuilding::schemaTranslate(const Quantity& quant,
// If this is zero, nothing to do but return
if (ntot == 0) {
return QString::fromLatin1("0");
return "0";
}
// Compute the whole number of feet and remaining units
@@ -293,22 +289,22 @@ QString UnitsSchemaImperialBuilding::schemaTranslate(const Quantity& quant,
}
// Done!
return QString::fromLatin1(output.str().c_str());
return output.str();
}
else if (unit == Unit::Angle) {
unitString = QString::fromUtf8("\xC2\xB0");
unitString = "\xC2\xB0";
factor = 1.0;
}
else if (unit == Unit::Area) {
unitString = QString::fromLatin1("sqft");
unitString = "sqft";
factor = 92903.04;
}
else if (unit == Unit::Volume) {
unitString = QString::fromLatin1("cft");
unitString = "cft";
factor = 28316846.592;
}
else if (unit == Unit::Velocity) {
unitString = QString::fromLatin1("in/min");
unitString = "in/min";
factor = 25.4 / 60;
}
else {
@@ -319,51 +315,50 @@ QString UnitsSchemaImperialBuilding::schemaTranslate(const Quantity& quant,
return toLocale(quant, factor, unitString);
}
QString UnitsSchemaImperialCivil::schemaTranslate(const Base::Quantity& quant,
double& factor,
QString& unitString)
std::string UnitsSchemaImperialCivil::schemaTranslate(const Base::Quantity& quant,
double& factor,
std::string& unitString)
{
// double UnitValue = std::abs(quant.getValue());
Unit unit = quant.getUnit();
// for imperial user/programmer mind; UnitValue is in internal system, that means
// mm/kg/s. And all combined units have to be calculated from there!
// now do special treatment on all cases seems necessary:
if (unit == Unit::Length) { // Length handling ============================
unitString = QString::fromLatin1("ft"); // always ft
factor = 304.8; // 12 * 25.4
if (unit == Unit::Length) { // Length handling ============================
unitString = "ft"; // always ft
factor = 304.8; // 12 * 25.4
}
else if (unit == Unit::Area) {
unitString = QString::fromLatin1("ft^2"); // always sq.ft
unitString = "ft^2"; // always sq.ft
factor = 92903.04;
}
else if (unit == Unit::Volume) {
unitString = QString::fromLatin1("ft^3"); // always cu. ft
unitString = "ft^3"; // always cu. ft
factor = 28316846.592;
}
else if (unit == Unit::Mass) {
unitString = QString::fromLatin1("lb"); // always lbs.
unitString = "lb"; // always lbs.
factor = 0.45359237;
}
else if (unit == Unit::Pressure) {
unitString = QString::fromLatin1("psi");
unitString = "psi";
factor = 6.894744825494;
}
else if (unit == Unit::Stiffness) {
unitString = QString::fromLatin1("lbf/in");
unitString = "lbf/in";
factor = 4.448222 / 0.0254;
}
else if (unit == Unit::Velocity) {
unitString = QString::fromLatin1("mph");
unitString = "mph";
factor = 447.04; // 1mm/sec => mph
}
// this schema expresses angles in degrees + minutes + seconds
else if (unit == Unit::Angle) {
unitString = QString::fromUtf8("deg");
QString degreeString = QString::fromUtf8("\xC2\xB0"); // degree symbol
QString minuteString = QString::fromUtf8("\xE2\x80\xB2"); // prime symbol
QString secondString = QString::fromUtf8("\xE2\x80\xB3"); // double prime symbol
factor = 1.0; // 1deg = 1"\xC2\xB0 "
unitString = "deg";
std::string degreeString = "\xC2\xB0"; // degree symbol
std::string minuteString = "\xE2\x80\xB2"; // prime symbol
std::string secondString = "\xE2\x80\xB3"; // double prime symbol
factor = 1.0; // 1deg = 1"\xC2\xB0 "
double totalDegrees = quant.getValue() / factor;
double wholeDegrees = std::floor(totalDegrees);
@@ -378,12 +373,12 @@ QString UnitsSchemaImperialCivil::schemaTranslate(const Base::Quantity& quant,
int outSec = static_cast<int>(std::round(rawSeconds));
std::stringstream output;
output << outDeg << degreeString.toUtf8().constData();
output << outDeg << degreeString;
if ((outMin > 0) || (outSec > 0)) {
output << outMin << minuteString.toUtf8().constData();
output << outMin << minuteString;
}
if (outSec > 0) {
output << outSec << secondString.toUtf8().constData();
output << outSec << secondString;
}
// uncomment this for decimals on seconds
// if (remainSeconds < (1.0 * pow(10.0,-Base::UnitsApi::getDecimals())) ) {
@@ -392,7 +387,7 @@ QString UnitsSchemaImperialCivil::schemaTranslate(const Base::Quantity& quant,
// output << std::setprecision(Base::UnitsApi::getDecimals()) << std::fixed <<
// rawSeconds << secondString.toStdString();
// }
return QString::fromUtf8(output.str().c_str());
return output.str();
}
else {
// default action for all cases without special treatment:
+8 -22
View File
@@ -20,18 +20,14 @@
* *
***************************************************************************/
#ifndef BASE_UNITSSCHEMAIMPERIAL1_H
#define BASE_UNITSSCHEMAIMPERIAL1_H
#include <QString>
#include "UnitsSchema.h"
namespace Base
{
/** The schema class for the imperial unit system
* Here are the definitions for the imperial unit system.
* It also defines how the value/units get printed.
@@ -39,10 +35,8 @@ namespace Base
class UnitsSchemaImperial1: public UnitsSchema
{
public:
// virtual void setSchemaUnits(void);
// virtual void resetSchemaUnits(void);
QString
schemaTranslate(const Base::Quantity& quant, double& factor, QString& unitString) override;
std::string
schemaTranslate(const Base::Quantity& quant, double& factor, std::string& unitString) override;
std::string getBasicLengthUnit() const override
{
return {"in"};
@@ -56,10 +50,8 @@ public:
class UnitsSchemaImperialDecimal: public UnitsSchema
{
public:
// virtual void setSchemaUnits(void);
// virtual void resetSchemaUnits(void);
QString
schemaTranslate(const Base::Quantity& quant, double& factor, QString& unitString) override;
std::string
schemaTranslate(const Base::Quantity& quant, double& factor, std::string& unitString) override;
std::string getBasicLengthUnit() const override
{
return {"in"};
@@ -73,10 +65,8 @@ public:
class UnitsSchemaImperialBuilding: public UnitsSchema
{
public:
// virtual void setSchemaUnits(void);
// virtual void resetSchemaUnits(void);
QString
schemaTranslate(const Base::Quantity& quant, double& factor, QString& unitString) override;
std::string
schemaTranslate(const Base::Quantity& quant, double& factor, std::string& unitString) override;
std::string getBasicLengthUnit() const override
{
return {"ft"};
@@ -96,10 +86,8 @@ public:
class UnitsSchemaImperialCivil: public UnitsSchema
{
public:
// virtual void setSchemaUnits(void);
// virtual void resetSchemaUnits(void);
QString
schemaTranslate(const Base::Quantity& quant, double& factor, QString& unitString) override;
std::string
schemaTranslate(const Base::Quantity& quant, double& factor, std::string& unitString) override;
std::string getBasicLengthUnit() const override
{
return {"ft"};
@@ -112,8 +100,6 @@ public:
}
};
} // namespace Base
#endif // BASE_UNITSSCHEMAIMPERIAL1_H
+135 -135
View File
@@ -26,17 +26,13 @@
#include <unistd.h>
#endif
#include <QString>
#include "UnitsSchemaInternal.h"
#include <cmath>
using namespace Base;
QString
UnitsSchemaInternal::schemaTranslate(const Quantity& quant, double& factor, QString& unitString)
std::string
UnitsSchemaInternal::schemaTranslate(const Quantity& quant, double& factor, std::string& unitString)
{
double UnitValue = std::abs(quant.getValue());
Unit unit = quant.getUnit();
@@ -52,575 +48,579 @@ UnitsSchemaInternal::schemaTranslate(const Quantity& quant, double& factor, QStr
// now do special treatment on all cases seems necessary:
if (unit == Unit::Length) { // Length handling ============================
if (UnitValue < 1e-6) { // smaller than 0.001 nm -> scientific notation
unitString = QString::fromLatin1("mm");
unitString = "mm";
factor = 1.0;
}
else if (UnitValue < 1e-3) {
unitString = QString::fromLatin1("nm");
unitString = "nm";
factor = 1e-6;
}
else if (UnitValue < 0.1) {
unitString = QString::fromUtf8("\xC2\xB5m");
unitString = "\xC2\xB5m";
factor = 1e-3;
}
else if (UnitValue < 1e4) {
unitString = QString::fromLatin1("mm");
unitString = "mm";
factor = 1.0;
}
else if (UnitValue < 1e7) {
unitString = QString::fromLatin1("m");
unitString = "m";
factor = 1e3;
}
else if (UnitValue < 1e10) {
unitString = QString::fromLatin1("km");
unitString = "km";
factor = 1e6;
}
else { // bigger than 1000 km -> scientific notation
unitString = QString::fromLatin1("m");
unitString = "m";
factor = 1e3;
}
}
else if (unit == Unit::Area) {
if (UnitValue < 100) {
unitString = QString::fromLatin1("mm^2");
unitString = "mm^2";
factor = 1.0;
}
else if (UnitValue < 1e6) {
unitString = QString::fromLatin1("cm^2");
unitString = "cm^2";
factor = 100;
}
else if (UnitValue < 1e12) {
unitString = QString::fromLatin1("m^2");
unitString = "m^2";
factor = 1e6;
}
else { // bigger than 1 square kilometer
unitString = QString::fromLatin1("km^2");
unitString = "km^2";
factor = 1e12;
}
}
else if (unit == Unit::Volume) {
if (UnitValue < 1e3) { // smaller than 1 ul
unitString = QString::fromLatin1("mm^3");
unitString = "mm^3";
factor = 1.0;
}
else if (UnitValue < 1e6) {
unitString = QString::fromLatin1("ml");
unitString = "ml";
factor = 1e3;
}
else if (UnitValue < 1e9) {
unitString = QString::fromLatin1("l");
unitString = "l";
factor = 1e6;
}
else { // bigger than 1000 l
unitString = QString::fromLatin1("m^3");
unitString = "m^3";
factor = 1e9;
}
}
else if (unit == Unit::Angle) {
// TODO: Cascade for the Areas
// default action for all cases without special treatment:
unitString = QString::fromUtf8("\xC2\xB0");
unitString = "\xC2\xB0";
factor = 1.0;
}
else if (unit == Unit::Mass) {
if (UnitValue < 1e-6) {
unitString = QString::fromUtf8("\xC2\xB5g");
unitString = "\xC2\xB5g";
factor = 1e-9;
}
else if (UnitValue < 1e-3) {
unitString = QString::fromLatin1("mg");
unitString = "mg";
factor = 1e-6;
}
else if (UnitValue < 1.0) {
unitString = QString::fromLatin1("g");
unitString = "g";
factor = 1e-3;
}
else if (UnitValue < 1e3) {
unitString = QString::fromLatin1("kg");
unitString = "kg";
factor = 1.0;
}
else {
unitString = QString::fromLatin1("t");
unitString = "t";
factor = 1e3;
}
}
else if (unit == Unit::Density) {
if (UnitValue < 0.0001) {
unitString = QString::fromLatin1("kg/m^3");
unitString = "kg/m^3";
factor = 1e-9;
}
else if (UnitValue < 1.0) {
unitString = QString::fromLatin1("kg/cm^3");
unitString = "kg/cm^3";
factor = 0.001;
}
else {
unitString = QString::fromLatin1("kg/mm^3");
unitString = "kg/mm^3";
factor = 1.0;
}
}
else if (unit == Unit::ThermalConductivity) {
if (UnitValue > 1e6) {
unitString = QString::fromLatin1("W/mm/K");
unitString = "W/mm/K";
factor = 1e6;
}
else {
unitString = QString::fromLatin1("W/m/K");
unitString = "W/m/K";
factor = 1000.0;
}
}
else if (unit == Unit::ThermalExpansionCoefficient) {
if (UnitValue < 0.001) {
unitString = QString::fromUtf8("\xC2\xB5m/m/K"); // micro-meter/meter/K
unitString = "\xC2\xB5m/m/K"; // micro-meter/meter/K
factor = 1e-6;
}
else {
unitString = QString::fromLatin1("mm/mm/K");
unitString = "mm/mm/K";
factor = 1.0;
}
}
else if (unit == Unit::VolumetricThermalExpansionCoefficient) {
if (UnitValue < 0.001) {
unitString = QString::fromUtf8("mm^3/m^3/K");
unitString = "mm^3/m^3/K";
factor = 1e-9;
}
else {
unitString = QString::fromLatin1("m^3/m^3/K");
unitString = "m^3/m^3/K";
factor = 1.0;
}
}
else if (unit == Unit::SpecificHeat) {
unitString = QString::fromLatin1("J/kg/K");
unitString = "J/kg/K";
factor = 1e6;
}
else if (unit == Unit::ThermalTransferCoefficient) {
unitString = QString::fromLatin1("W/m^2/K");
unitString = "W/m^2/K";
factor = 1.0;
}
else if ((unit == Unit::Pressure) || (unit == Unit::Stress)) {
if (UnitValue < 10.0) { // Pa is the smallest
unitString = QString::fromLatin1("Pa");
unitString = "Pa";
factor = 0.001;
}
else if (UnitValue < 10000.0) {
unitString = QString::fromLatin1("kPa");
unitString = "kPa";
factor = 1.0;
}
else if (UnitValue < 10000000.0) {
unitString = QString::fromLatin1("MPa");
unitString = "MPa";
factor = 1000.0;
}
else if (UnitValue < 10000000000.0) {
unitString = QString::fromLatin1("GPa");
unitString = "GPa";
factor = 1e6;
}
else { // bigger -> scientific notation
unitString = QString::fromLatin1("Pa");
unitString = "Pa";
factor = 0.001;
}
}
else if ((unit == Unit::Stiffness)) {
if (UnitValue < 1) { // mN/m is the smallest
unitString = QString::fromLatin1("mN/m");
unitString = "mN/m";
factor = 1e-3;
}
else if (UnitValue < 1e3) {
unitString = QString::fromLatin1("N/m");
unitString = "N/m";
factor = 1.0;
}
else if (UnitValue < 1e6) {
unitString = QString::fromLatin1("kN/m");
unitString = "kN/m";
factor = 1e3;
}
else {
unitString = QString::fromLatin1("MN/m");
unitString = "MN/m";
factor = 1e6;
}
}
else if ((unit == Unit::StiffnessDensity)) {
if (UnitValue < 1e-3) {
unitString = QString::fromLatin1("Pa/m");
unitString = "Pa/m";
factor = 1e-6;
}
else if (UnitValue < 1) {
unitString = QString::fromLatin1("kPa/m");
unitString = "kPa/m";
factor = 1e-3;
}
else if (UnitValue < 1e3) {
unitString = QString::fromLatin1("MPa/m");
unitString = "MPa/m";
factor = 1.0;
}
else {
unitString = QString::fromLatin1("GPa/m");
unitString = "GPa/m";
factor = 1e3;
}
}
else if (unit == Unit::Force) {
if (UnitValue < 1e3) {
unitString = QString::fromLatin1("mN");
unitString = "mN";
factor = 1.0;
}
else if (UnitValue < 1e6) {
unitString = QString::fromLatin1("N");
unitString = "N";
factor = 1e3;
}
else if (UnitValue < 1e9) {
unitString = QString::fromLatin1("kN");
unitString = "kN";
factor = 1e6;
}
else {
unitString = QString::fromLatin1("MN");
unitString = "MN";
factor = 1e9;
}
}
// else if (unit == Unit::Moment) {
// if (UnitValue < 1e6) {
// unitString = QString::fromLatin1("mNm");
// unitString = "mNm";
// factor = 1e3;
// }
// else if (UnitValue < 1e9) {
// unitString = QString::fromLatin1("Nm");
// unitString = "Nm";
// factor = 1e6;
// }
// else if (UnitValue < 1e12) {
// unitString = QString::fromLatin1("kNm");
// unitString = "kNm";
// factor = 1e9;
// }
// else {
// unitString = QString::fromLatin1("MNm");
// unitString = "MNm";
// factor = 1e12;
// }
// }
else if (unit == Unit::Power) {
if (UnitValue < 1e6) {
unitString = QString::fromLatin1("mW");
unitString = "mW";
factor = 1e3;
}
else if (UnitValue < 1e9) {
unitString = QString::fromLatin1("W");
unitString = "W";
factor = 1e6;
}
else {
unitString = QString::fromLatin1("kW");
unitString = "kW";
factor = 1e9;
}
}
else if (unit == Unit::ElectricPotential) {
if (UnitValue < 1e6) {
unitString = QString::fromLatin1("mV");
unitString = "mV";
factor = 1e3;
}
else if (UnitValue < 1e9) {
unitString = QString::fromLatin1("V");
unitString = "V";
factor = 1e6;
}
else if (UnitValue < 1e12) {
unitString = QString::fromLatin1("kV");
unitString = "kV";
factor = 1e9;
}
else { // > 1000 kV scientificc notation
unitString = QString::fromLatin1("V");
unitString = "V";
factor = 1e6;
}
}
else if (unit == Unit::Work) {
if (UnitValue < 1.602176634e-10) {
unitString = QString::fromLatin1("eV");
unitString = "eV";
factor = 1.602176634e-13;
}
else if (UnitValue < 1.602176634e-7) {
unitString = QString::fromLatin1("keV");
unitString = "keV";
factor = 1.602176634e-10;
}
else if (UnitValue < 1.602176634e-4) {
unitString = QString::fromLatin1("MeV");
unitString = "MeV";
factor = 1.602176634e-7;
}
else if (UnitValue < 1e6) {
unitString = QString::fromLatin1("mJ");
unitString = "mJ";
factor = 1e3;
}
else if (UnitValue < 1e9) {
unitString = QString::fromLatin1("J");
unitString = "J";
factor = 1e6;
}
else if (UnitValue < 1e12) {
unitString = QString::fromLatin1("kJ");
unitString = "kJ";
factor = 1e9;
}
else if (UnitValue < 3.6e+15) {
unitString = QString::fromLatin1("kWh");
unitString = "kWh";
factor = 3.6e+12;
}
else { // bigger than 1000 kWh -> scientific notation
unitString = QString::fromLatin1("J");
unitString = "J";
factor = 1e6;
}
}
else if (unit == Unit::SpecificEnergy) {
unitString = QString::fromLatin1("m^2/s^2");
unitString = "m^2/s^2";
factor = 1e6;
}
else if (unit == Unit::HeatFlux) {
unitString = QString::fromLatin1("W/m^2");
unitString = "W/m^2";
factor = 1; // unit signature (0,1,-3,0,0) is length independent
}
else if (unit == Unit::ElectricCharge) {
unitString = QString::fromLatin1("C");
unitString = "C";
factor = 1.0;
}
else if (unit == Unit::CurrentDensity) {
if (UnitValue <= 1e3) {
unitString = QString::fromLatin1("A/m^2");
unitString = "A/m^2";
factor = 1e-6;
}
else {
unitString = QString::fromLatin1("A/mm^2");
unitString = "A/mm^2";
factor = 1;
}
}
else if (unit == Unit::MagneticFluxDensity) {
if (UnitValue <= 1e-3) {
unitString = QString::fromLatin1("G");
unitString = "G";
factor = 1e-4;
}
else {
unitString = QString::fromLatin1("T");
unitString = "T";
factor = 1.0;
}
}
else if (unit == Unit::MagneticFieldStrength) {
unitString = QString::fromLatin1("A/m");
unitString = "A/m";
factor = 1e-3;
}
else if (unit == Unit::MagneticFlux) {
unitString = QString::fromLatin1("Wb");
unitString = "Wb";
factor = 1e6;
}
else if (unit == Unit::Magnetization) {
unitString = QString::fromLatin1("A/m");
unitString = "A/m";
factor = 1e-3;
}
else if (unit == Unit::ElectromagneticPotential) {
unitString = "Wb/m";
factor = 1e3;
}
else if (unit == Unit::ElectricalConductance) {
if (UnitValue < 1e-9) {
unitString = QString::fromUtf8("\xC2\xB5S");
unitString = "\xC2\xB5S";
factor = 1e-12;
}
else if (UnitValue < 1e-6) {
unitString = QString::fromLatin1("mS");
unitString = "mS";
factor = 1e-9;
}
else {
unitString = QString::fromLatin1("S");
unitString = "S";
factor = 1e-6;
}
}
else if (unit == Unit::ElectricalResistance) {
if (UnitValue < 1e9) {
unitString = QString::fromLatin1("Ohm");
unitString = "Ohm";
factor = 1e6;
}
else if (UnitValue < 1e12) {
unitString = QString::fromLatin1("kOhm");
unitString = "kOhm";
factor = 1e9;
}
else {
unitString = QString::fromLatin1("MOhm");
unitString = "MOhm";
factor = 1e12;
}
}
else if (unit == Unit::ElectricalConductivity) {
if (UnitValue < 1e-3) {
unitString = QString::fromLatin1("mS/m");
unitString = "mS/m";
factor = 1e-12;
}
else if (UnitValue < 1.0) {
unitString = QString::fromLatin1("S/m");
unitString = "S/m";
factor = 1e-9;
}
else if (UnitValue < 1e3) {
unitString = QString::fromLatin1("kS/m");
unitString = "kS/m";
factor = 1e-6;
}
else {
unitString = QString::fromLatin1("MS/m");
unitString = "MS/m";
factor = 1e-3;
}
}
else if (unit == Unit::ElectricalCapacitance) {
if (UnitValue < 1e-15) {
unitString = QString::fromLatin1("pF");
unitString = "pF";
factor = 1e-18;
}
else if (UnitValue < 1e-12) {
unitString = QString::fromLatin1("nF");
unitString = "nF";
factor = 1e-15;
}
else if (UnitValue < 1e-9) {
// \x reads everything to the end, therefore split
unitString = QString::fromUtf8("\xC2\xB5"
"F");
unitString = "\xC2\xB5"
"F";
factor = 1e-12;
}
else if (UnitValue < 1e-6) {
unitString = QString::fromLatin1("mF");
unitString = "mF";
factor = 1e-9;
}
else {
unitString = QString::fromLatin1("F");
unitString = "F";
factor = 1e-6;
}
}
else if (unit == Unit::ElectricalInductance) {
if (UnitValue < 1.0) {
unitString = QString::fromLatin1("nH");
unitString = "nH";
factor = 1e-3;
}
else if (UnitValue < 1e3) {
unitString = QString::fromUtf8("\xC2\xB5H");
unitString = "\xC2\xB5H";
factor = 1.0;
}
else if (UnitValue < 1e6) {
unitString = QString::fromLatin1("mH");
unitString = "mH";
factor = 1e3;
}
else {
unitString = QString::fromLatin1("H");
unitString = "H";
factor = 1e6;
}
}
else if (unit == Unit::VacuumPermittivity) {
unitString = QString::fromLatin1("F/m");
unitString = "F/m";
factor = 1e-9;
}
else if (unit == Unit::Frequency) {
if (UnitValue < 1e3) {
unitString = QString::fromLatin1("Hz");
unitString = "Hz";
factor = 1.0;
}
else if (UnitValue < 1e6) {
unitString = QString::fromLatin1("kHz");
unitString = "kHz";
factor = 1e3;
}
else if (UnitValue < 1e9) {
unitString = QString::fromLatin1("MHz");
unitString = "MHz";
factor = 1e6;
}
else if (UnitValue < 1e12) {
unitString = QString::fromLatin1("GHz");
unitString = "GHz";
factor = 1e9;
}
else {
unitString = QString::fromLatin1("THz");
unitString = "THz";
factor = 1e12;
}
}
else if (unit == Unit::Velocity) {
unitString = QString::fromLatin1("mm/s");
unitString = "mm/s";
factor = 1.0;
}
else if (unit == Unit::DynamicViscosity) {
unitString = QString::fromLatin1("Pa*s");
unitString = "Pa*s";
factor = 0.001;
}
else if (unit == Unit::KinematicViscosity) {
if (UnitValue < 1e3) {
unitString = QString::fromLatin1("mm^2/s");
unitString = "mm^2/s";
factor = 1.0;
}
else {
unitString = QString::fromLatin1("m^2/s");
unitString = "m^2/s";
factor = 1e6;
}
}
else if (unit == Unit::VolumeFlowRate) {
if (UnitValue < 1e3) {
unitString = QString::fromLatin1("mm^3/s");
unitString = "mm^3/s";
factor = 1.0;
}
else if (UnitValue < 1e6) {
unitString = QString::fromLatin1("ml/s");
unitString = "ml/s";
factor = 1e3;
}
else if (UnitValue < 1e9) {
unitString = QString::fromLatin1("l/s");
unitString = "l/s";
factor = 1e6;
}
else {
unitString = QString::fromLatin1("m^3/s");
unitString = "m^3/s";
factor = 1e9;
}
}
else if (unit == Unit::DissipationRate) {
unitString = QString::fromLatin1("W/kg");
unitString = "W/kg";
factor = 1e6;
}
else if (unit == Unit::InverseLength) {
if (UnitValue < 1e-6) { // smaller than 0.001 1/km -> scientific notation
unitString = QString::fromLatin1("1/m");
unitString = "1/m";
factor = 1e-3;
}
else if (UnitValue < 1e-3) {
unitString = QString::fromLatin1("1/km");
unitString = "1/km";
factor = 1e-6;
}
else if (UnitValue < 1.0) {
unitString = QString::fromLatin1("1/m");
unitString = "1/m";
factor = 1e-3;
}
else if (UnitValue < 1e3) {
unitString = QString::fromLatin1("1/mm");
unitString = "1/mm";
factor = 1.0;
}
else if (UnitValue < 1e6) {
unitString = QString::fromUtf8("1/\xC2\xB5m");
unitString = "1/\xC2\xB5m";
factor = 1e3;
}
else if (UnitValue < 1e9) {
unitString = QString::fromLatin1("1/nm");
unitString = "1/nm";
factor = 1e6;
}
else { // larger -> scientific notation
unitString = QString::fromLatin1("1/m");
unitString = "1/m";
factor = 1e-3;
}
}
else if (unit == Unit::InverseArea) {
if (UnitValue < 1e-12) { // smaller than 0.001 1/km^2 -> scientific notation
unitString = QString::fromLatin1("1/m^2");
unitString = "1/m^2";
factor = 1e-6;
}
else if (UnitValue < 1e-6) {
unitString = QString::fromLatin1("1/km^2");
unitString = "1/km^2";
factor = 1e-12;
}
else if (UnitValue < 1.0) {
unitString = QString::fromLatin1("1/m^2");
unitString = "1/m^2";
factor = 1e-6;
}
else if (UnitValue < 1e2) {
unitString = QString::fromLatin1("1/cm^2");
unitString = "1/cm^2";
factor = 1e-2;
}
else {
unitString = QString::fromLatin1("1/mm^2");
unitString = "1/mm^2";
factor = 1.0;
}
}
else if (unit == Unit::InverseVolume) {
if (UnitValue < 1e-6) {
unitString = QString::fromLatin1("1/m^3");
unitString = "1/m^3";
factor = 1e-9;
}
else if (UnitValue < 1e-3) {
unitString = QString::fromLatin1("1/l");
unitString = "1/l";
factor = 1e-6;
}
else if (UnitValue < 1.0) {
unitString = QString::fromLatin1("1/ml");
unitString = "1/ml";
factor = 1e-3;
}
else {
unitString = QString::fromLatin1("1/mm^3");
unitString = "1/mm^3";
factor = 1.0;
}
}
+2 -8
View File
@@ -20,18 +20,14 @@
* *
***************************************************************************/
#ifndef BASE_UNITSSCHEMAINTERNAL_H
#define BASE_UNITSSCHEMAINTERNAL_H
#include <QString>
#include "UnitsSchema.h"
namespace Base
{
/** The standard units schema
* Here is defined what internal (base) units FreeCAD uses.
* FreeCAD uses a mm/kg/deg scala.
@@ -40,12 +36,10 @@ namespace Base
class UnitsSchemaInternal: public UnitsSchema
{
public:
QString
schemaTranslate(const Base::Quantity& quant, double& factor, QString& unitString) override;
std::string
schemaTranslate(const Base::Quantity& quant, double& factor, std::string& unitString) override;
};
} // namespace Base
#endif // BASE_UNITSSCHEMAINTERNAL_H
+135 -134
View File
@@ -26,16 +26,13 @@
#include <unistd.h>
#endif
#include <QString>
#include "UnitsSchemaMKS.h"
#include <cmath>
using namespace Base;
QString UnitsSchemaMKS::schemaTranslate(const Quantity& quant, double& factor, QString& unitString)
std::string
UnitsSchemaMKS::schemaTranslate(const Quantity& quant, double& factor, std::string& unitString)
{
double UnitValue = std::abs(quant.getValue());
Unit unit = quant.getUnit();
@@ -43,571 +40,575 @@ QString UnitsSchemaMKS::schemaTranslate(const Quantity& quant, double& factor, Q
// now do special treatment on all cases seems necessary:
if (unit == Unit::Length) { // Length handling ============================
if (UnitValue < 1e-6) { // smaller than 0.001 nm -> scientific notation
unitString = QString::fromLatin1("mm");
unitString = "mm";
factor = 1.0;
}
else if (UnitValue < 1e-3) {
unitString = QString::fromLatin1("nm");
unitString = "nm";
factor = 1e-6;
}
else if (UnitValue < 0.1) {
unitString = QString::fromUtf8("\xC2\xB5m");
unitString = "\xC2\xB5m";
factor = 1e-3;
}
else if (UnitValue < 1e4) {
unitString = QString::fromLatin1("mm");
unitString = "mm";
factor = 1.0;
}
else if (UnitValue < 1e7) {
unitString = QString::fromLatin1("m");
unitString = "m";
factor = 1e3;
}
else if (UnitValue < 1e10) {
unitString = QString::fromLatin1("km");
unitString = "km";
factor = 1e6;
}
else { // bigger than 1000 km -> scientific notation
unitString = QString::fromLatin1("m");
unitString = "m";
factor = 1e3;
}
}
else if (unit == Unit::Area) {
if (UnitValue < 100) {
unitString = QString::fromLatin1("mm^2");
unitString = "mm^2";
factor = 1.0;
}
else if (UnitValue < 1e6) {
unitString = QString::fromLatin1("cm^2");
unitString = "cm^2";
factor = 100;
}
else if (UnitValue < 1e12) {
unitString = QString::fromLatin1("m^2");
unitString = "m^2";
factor = 1e6;
}
else { // bigger than 1 square kilometer
unitString = QString::fromLatin1("km^2");
unitString = "km^2";
factor = 1e12;
}
}
else if (unit == Unit::Volume) {
if (UnitValue < 1e3) { // smaller than 1 ul
unitString = QString::fromLatin1("mm^3");
unitString = "mm^3";
factor = 1.0;
}
else if (UnitValue < 1e6) {
unitString = QString::fromLatin1("ml");
unitString = "ml";
factor = 1e3;
}
else if (UnitValue < 1e9) {
unitString = QString::fromLatin1("l");
unitString = "l";
factor = 1e6;
}
else { // bigger than 1000 l
unitString = QString::fromLatin1("m^3");
unitString = "m^3";
factor = 1e9;
}
}
else if (unit == Unit::Mass) {
if (UnitValue < 1e-6) {
unitString = QString::fromUtf8("\xC2\xB5g");
unitString = "\xC2\xB5g";
factor = 1e-9;
}
else if (UnitValue < 1e-3) {
unitString = QString::fromLatin1("mg");
unitString = "mg";
factor = 1e-6;
}
else if (UnitValue < 1.0) {
unitString = QString::fromLatin1("g");
unitString = "g";
factor = 1e-3;
}
else if (UnitValue < 1e3) {
unitString = QString::fromLatin1("kg");
unitString = "kg";
factor = 1.0;
}
else {
unitString = QString::fromLatin1("t");
unitString = "t";
factor = 1e3;
}
}
else if (unit == Unit::Density) {
if (UnitValue < 0.0001) {
unitString = QString::fromLatin1("kg/m^3");
unitString = "kg/m^3";
factor = 0.000000001;
}
else if (UnitValue < 1.0) {
unitString = QString::fromLatin1("kg/cm^3");
unitString = "kg/cm^3";
factor = 0.001;
}
else {
unitString = QString::fromLatin1("kg/mm^3");
unitString = "kg/mm^3";
factor = 1.0;
}
}
else if (unit == Unit::Acceleration) {
unitString = QString::fromLatin1("m/s^2");
unitString = "m/s^2";
factor = 1000.0;
}
else if ((unit == Unit::Pressure) || (unit == Unit::Stress)) {
if (UnitValue < 10.0) { // Pa is the smallest
unitString = QString::fromLatin1("Pa");
unitString = "Pa";
factor = 0.001;
}
else if (UnitValue < 10000.0) {
unitString = QString::fromLatin1("kPa");
unitString = "kPa";
factor = 1.0;
}
else if (UnitValue < 10000000.0) {
unitString = QString::fromLatin1("MPa");
unitString = "MPa";
factor = 1000.0;
}
else if (UnitValue < 10000000000.0) {
unitString = QString::fromLatin1("GPa");
unitString = "GPa";
factor = 1000000.0;
}
else { // bigger then 1000 GPa -> scientific notation
unitString = QString::fromLatin1("Pa");
unitString = "Pa";
factor = 0.001;
}
}
else if ((unit == Unit::Stiffness)) {
if (UnitValue < 1) { // mN/m is the smallest
unitString = QString::fromLatin1("mN/m");
unitString = "mN/m";
factor = 1e-3;
}
else if (UnitValue < 1e3) {
unitString = QString::fromLatin1("N/m");
unitString = "N/m";
factor = 1.0;
}
else if (UnitValue < 1e6) {
unitString = QString::fromLatin1("kN/m");
unitString = "kN/m";
factor = 1e3;
}
else {
unitString = QString::fromLatin1("MN/m");
unitString = "MN/m";
factor = 1e6;
}
}
else if ((unit == Unit::StiffnessDensity)) {
if (UnitValue < 1e-3) {
unitString = QString::fromLatin1("Pa/m");
unitString = "Pa/m";
factor = 1e-6;
}
else if (UnitValue < 1) {
unitString = QString::fromLatin1("kPa/m");
unitString = "kPa/m";
factor = 1e-3;
}
else if (UnitValue < 1e3) {
unitString = QString::fromLatin1("MPa/m");
unitString = "MPa/m";
factor = 1.0;
}
else {
unitString = QString::fromLatin1("GPa/m");
unitString = "GPa/m";
factor = 1e3;
}
}
else if (unit == Unit::ThermalConductivity) {
if (UnitValue > 1000000) {
unitString = QString::fromLatin1("W/mm/K");
unitString = "W/mm/K";
factor = 1000000.0;
}
else {
unitString = QString::fromLatin1("W/m/K");
unitString = "W/m/K";
factor = 1000.0;
}
}
else if (unit == Unit::ThermalExpansionCoefficient) {
if (UnitValue < 0.001) {
unitString = QString::fromUtf8("\xC2\xB5m/m/K");
unitString = "\xC2\xB5m/m/K";
factor = 0.000001;
}
else {
unitString = QString::fromLatin1("m/m/K");
unitString = "m/m/K";
factor = 1.0;
}
}
else if (unit == Unit::VolumetricThermalExpansionCoefficient) {
if (UnitValue < 0.001) {
unitString = QString::fromUtf8("mm^3/m^3/K");
unitString = "mm^3/m^3/K";
factor = 1e-9;
}
else {
unitString = QString::fromLatin1("m^3/m^3/K");
unitString = "m^3/m^3/K";
factor = 1.0;
}
}
else if (unit == Unit::SpecificHeat) {
unitString = QString::fromLatin1("J/kg/K");
unitString = "J/kg/K";
factor = 1000000.0;
}
else if (unit == Unit::ThermalTransferCoefficient) {
unitString = QString::fromLatin1("W/m^2/K");
unitString = "W/m^2/K";
factor = 1.0;
}
else if (unit == Unit::Force) {
if (UnitValue < 1e3) {
unitString = QString::fromLatin1("mN");
unitString = "mN";
factor = 1.0;
}
else if (UnitValue < 1e6) {
unitString = QString::fromLatin1("N");
unitString = "N";
factor = 1e3;
}
else if (UnitValue < 1e9) {
unitString = QString::fromLatin1("kN");
unitString = "kN";
factor = 1e6;
}
else {
unitString = QString::fromLatin1("MN");
unitString = "MN";
factor = 1e9;
}
}
// else if (unit == Unit::Moment) {
// if (UnitValue < 1e6) {
// unitString = QString::fromLatin1("mNm");
// unitString = "mNm";
// factor = 1e3;
// }
// else if (UnitValue < 1e9) {
// unitString = QString::fromLatin1("Nm");
// unitString = "Nm";
// factor = 1e6;
// }
// else if (UnitValue < 1e12) {
// unitString = QString::fromLatin1("kNm");
// unitString = "kNm";
// factor = 1e9;
// }
// else {
// unitString = QString::fromLatin1("MNm");
// unitString = "MNm";
// factor = 1e12;
// }
// }
else if (unit == Unit::Power) {
if (UnitValue < 1e6) {
unitString = QString::fromLatin1("mW");
unitString = "mW";
factor = 1e3;
}
else if (UnitValue < 1e9) {
unitString = QString::fromLatin1("W");
unitString = "W";
factor = 1e6;
}
else {
unitString = QString::fromLatin1("kW");
unitString = "kW";
factor = 1e9;
}
}
else if (unit == Unit::ElectricPotential) {
if (UnitValue < 1e6) {
unitString = QString::fromLatin1("mV");
unitString = "mV";
factor = 1e3;
}
else if (UnitValue < 1e9) {
unitString = QString::fromLatin1("V");
unitString = "V";
factor = 1e6;
}
else if (UnitValue < 1e12) {
unitString = QString::fromLatin1("kV");
unitString = "kV";
factor = 1e9;
}
else { // > 1000 kV scientificc notation
unitString = QString::fromLatin1("V");
unitString = "V";
factor = 1e6;
}
}
else if (unit == Unit::ElectricCharge) {
unitString = QString::fromLatin1("C");
unitString = "C";
factor = 1.0;
}
else if (unit == Unit::CurrentDensity) {
if (UnitValue <= 1e3) {
unitString = QString::fromLatin1("A/m^2");
unitString = "A/m^2";
factor = 1e-6;
}
else {
unitString = QString::fromLatin1("A/mm^2");
unitString = "A/mm^2";
factor = 1;
}
}
else if (unit == Unit::MagneticFluxDensity) {
if (UnitValue <= 1e-3) {
unitString = QString::fromLatin1("G");
unitString = "G";
factor = 1e-4;
}
else {
unitString = QString::fromLatin1("T");
unitString = "T";
factor = 1.0;
}
}
else if (unit == Unit::MagneticFieldStrength) {
unitString = QString::fromLatin1("A/m");
unitString = "A/m";
factor = 1e-3;
}
else if (unit == Unit::MagneticFlux) {
unitString = QString::fromLatin1("Wb");
unitString = "Wb";
factor = 1e6;
}
else if (unit == Unit::Magnetization) {
unitString = QString::fromLatin1("A/m");
unitString = "A/m";
factor = 1e-3;
}
else if (unit == Unit::ElectromagneticPotential) {
unitString = "Wb/m";
factor = 1e3;
}
else if (unit == Unit::ElectricalConductance) {
if (UnitValue < 1e-9) {
unitString = QString::fromUtf8("\xC2\xB5S");
unitString = "\xC2\xB5S";
factor = 1e-12;
}
else if (UnitValue < 1e-6) {
unitString = QString::fromLatin1("mS");
unitString = "mS";
factor = 1e-9;
}
else {
unitString = QString::fromLatin1("S");
unitString = "S";
factor = 1e-6;
}
}
else if (unit == Unit::ElectricalResistance) {
if (UnitValue < 1e9) {
unitString = QString::fromLatin1("Ohm");
unitString = "Ohm";
factor = 1e6;
}
else if (UnitValue < 1e12) {
unitString = QString::fromLatin1("kOhm");
unitString = "kOhm";
factor = 1e9;
}
else {
unitString = QString::fromLatin1("MOhm");
unitString = "MOhm";
factor = 1e12;
}
}
else if (unit == Unit::ElectricalConductivity) {
if (UnitValue < 1e-3) {
unitString = QString::fromLatin1("mS/m");
unitString = "mS/m";
factor = 1e-12;
}
else if (UnitValue < 1.0) {
unitString = QString::fromLatin1("S/m");
unitString = "S/m";
factor = 1e-9;
}
else if (UnitValue < 1e3) {
unitString = QString::fromLatin1("kS/m");
unitString = "kS/m";
factor = 1e-6;
}
else {
unitString = QString::fromLatin1("MS/m");
unitString = "MS/m";
factor = 1e-3;
}
}
else if (unit == Unit::ElectricalCapacitance) {
if (UnitValue < 1e-15) {
unitString = QString::fromLatin1("pF");
unitString = "pF";
factor = 1e-18;
}
else if (UnitValue < 1e-12) {
unitString = QString::fromLatin1("nF");
unitString = "nF";
factor = 1e-15;
}
else if (UnitValue < 1e-9) {
// \x reads everything to the end, therefore split
unitString = QString::fromUtf8("\xC2\xB5"
"F");
unitString = "\xC2\xB5"
"F";
factor = 1e-12;
}
else if (UnitValue < 1e-6) {
unitString = QString::fromLatin1("mF");
unitString = "mF";
factor = 1e-9;
}
else {
unitString = QString::fromLatin1("F");
unitString = "F";
factor = 1e-6;
}
}
else if (unit == Unit::ElectricalInductance) {
if (UnitValue < 1e-6) {
unitString = QString::fromLatin1("nH");
unitString = "nH";
factor = 1e-3;
}
else if (UnitValue < 1e-3) {
unitString = QString::fromUtf8("\xC2\xB5H");
unitString = "\xC2\xB5H";
factor = 1.0;
}
else if (UnitValue < 1.0) {
unitString = QString::fromLatin1("mH");
unitString = "mH";
factor = 1e3;
}
else {
unitString = QString::fromLatin1("H");
unitString = "H";
factor = 1e6;
}
}
else if (unit == Unit::VacuumPermittivity) {
unitString = QString::fromLatin1("F/m");
unitString = "F/m";
factor = 1e-9;
}
else if (unit == Unit::Work) {
if (UnitValue < 1.602176634e-10) {
unitString = QString::fromLatin1("eV");
unitString = "eV";
factor = 1.602176634e-13;
}
else if (UnitValue < 1.602176634e-7) {
unitString = QString::fromLatin1("keV");
unitString = "keV";
factor = 1.602176634e-10;
}
else if (UnitValue < 1.602176634e-4) {
unitString = QString::fromLatin1("MeV");
unitString = "MeV";
factor = 1.602176634e-7;
}
else if (UnitValue < 1e6) {
unitString = QString::fromLatin1("mJ");
unitString = "mJ";
factor = 1e3;
}
else if (UnitValue < 1e9) {
unitString = QString::fromLatin1("J");
unitString = "J";
factor = 1e6;
}
else if (UnitValue < 1e12) {
unitString = QString::fromLatin1("kJ");
unitString = "kJ";
factor = 1e9;
}
else if (UnitValue < 3.6e+15) {
unitString = QString::fromLatin1("kWh");
unitString = "kWh";
factor = 3.6e+12;
}
else { // bigger than 1000 kWh -> scientific notation
unitString = QString::fromLatin1("J");
unitString = "J";
factor = 1e6;
}
}
else if (unit == Unit::SpecificEnergy) {
unitString = QString::fromLatin1("m^2/s^2");
unitString = "m^2/s^2";
factor = 1000000;
}
else if (unit == Unit::HeatFlux) {
unitString = QString::fromLatin1("W/m^2");
unitString = "W/m^2";
factor = 1.0;
}
else if (unit == Unit::Frequency) {
if (UnitValue < 1e3) {
unitString = QString::fromLatin1("Hz");
unitString = "Hz";
factor = 1.0;
}
else if (UnitValue < 1e6) {
unitString = QString::fromLatin1("kHz");
unitString = "kHz";
factor = 1e3;
}
else if (UnitValue < 1e9) {
unitString = QString::fromLatin1("MHz");
unitString = "MHz";
factor = 1e6;
}
else if (UnitValue < 1e12) {
unitString = QString::fromLatin1("GHz");
unitString = "GHz";
factor = 1e9;
}
else {
unitString = QString::fromLatin1("THz");
unitString = "THz";
factor = 1e12;
}
}
else if (unit == Unit::Velocity) {
unitString = QString::fromLatin1("m/s");
unitString = "m/s";
factor = 1000.0;
}
else if (unit == Unit::DynamicViscosity) {
unitString = QString::fromLatin1("Pa*s");
unitString = "Pa*s";
factor = 0.001;
}
else if (unit == Unit::KinematicViscosity) {
unitString = QString::fromLatin1("m^2/s");
unitString = "m^2/s";
factor = 1e6;
}
else if (unit == Unit::VolumeFlowRate) {
if (UnitValue < 1e-3) { // smaller than 0.001 mm^3/s -> scientific notation
unitString = QString::fromLatin1("m^3/s");
unitString = "m^3/s";
factor = 1e9;
}
else if (UnitValue < 1e3) {
unitString = QString::fromLatin1("mm^3/s");
unitString = "mm^3/s";
factor = 1.0;
}
else if (UnitValue < 1e6) {
unitString = QString::fromLatin1("ml/s");
unitString = "ml/s";
factor = 1e3;
}
else if (UnitValue < 1e9) {
unitString = QString::fromLatin1("l/s");
unitString = "l/s";
factor = 1e6;
}
else {
unitString = QString::fromLatin1("m^3/s");
unitString = "m^3/s";
factor = 1e9;
}
}
else if (unit == Unit::DissipationRate) {
unitString = QString::fromLatin1("W/kg");
unitString = "W/kg";
factor = 1e6;
}
else if (unit == Unit::InverseLength) {
if (UnitValue < 1e-6) { // smaller than 0.001 1/km -> scientific notation
unitString = QString::fromLatin1("1/m");
unitString = "1/m";
factor = 1e-3;
}
else if (UnitValue < 1e-3) {
unitString = QString::fromLatin1("1/km");
unitString = "1/km";
factor = 1e-6;
}
else if (UnitValue < 1.0) {
unitString = QString::fromLatin1("1/m");
unitString = "1/m";
factor = 1e-3;
}
else if (UnitValue < 1e3) {
unitString = QString::fromLatin1("1/mm");
unitString = "1/mm";
factor = 1.0;
}
else if (UnitValue < 1e6) {
unitString = QString::fromUtf8("1/\xC2\xB5m");
unitString = "1/\xC2\xB5m";
factor = 1e3;
}
else if (UnitValue < 1e9) {
unitString = QString::fromLatin1("1/nm");
unitString = "1/nm";
factor = 1e6;
}
else { // larger -> scientific notation
unitString = QString::fromLatin1("1/m");
unitString = "1/m";
factor = 1e-3;
}
}
else if (unit == Unit::InverseArea) {
if (UnitValue < 1e-12) { // smaller than 0.001 1/km^2 -> scientific notation
unitString = QString::fromLatin1("1/m^2");
unitString = "1/m^2";
factor = 1e-6;
}
else if (UnitValue < 1e-6) {
unitString = QString::fromLatin1("1/km^2");
unitString = "1/km^2";
factor = 1e-12;
}
else if (UnitValue < 1.0) {
unitString = QString::fromLatin1("1/m^2");
unitString = "1/m^2";
factor = 1e-6;
}
else if (UnitValue < 1e2) {
unitString = QString::fromLatin1("1/cm^2");
unitString = "1/cm^2";
factor = 1e-2;
}
else {
unitString = QString::fromLatin1("1/mm^2");
unitString = "1/mm^2";
factor = 1.0;
}
}
else if (unit == Unit::InverseVolume) {
if (UnitValue < 1e-6) {
unitString = QString::fromLatin1("1/m^3");
unitString = "1/m^3";
factor = 1e-9;
}
else if (UnitValue < 1e-3) {
unitString = QString::fromLatin1("1/l");
unitString = "1/l";
factor = 1e-6;
}
else if (UnitValue < 1.0) {
unitString = QString::fromLatin1("1/ml");
unitString = "1/ml";
factor = 1e-3;
}
else {
unitString = QString::fromLatin1("1/mm^3");
unitString = "1/mm^3";
factor = 1.0;
}
}
+2 -8
View File
@@ -20,30 +20,24 @@
* *
***************************************************************************/
#ifndef BASE_UNITSSCHEMAMKS_H
#define BASE_UNITSSCHEMAMKS_H
#include <QString>
#include "UnitsSchema.h"
namespace Base
{
/**
* The UnitSchema class
*/
class UnitsSchemaMKS: public UnitsSchema
{
public:
QString
schemaTranslate(const Base::Quantity& quant, double& factor, QString& unitString) override;
std::string
schemaTranslate(const Base::Quantity& quant, double& factor, std::string& unitString) override;
};
} // namespace Base
#endif // BASE_UNITSSCHEMAMKS_H
+25 -45
View File
@@ -29,60 +29,40 @@
*/
#include "PreCompiled.h"
#ifdef __GNUC__
#include <unistd.h>
#ifndef _PreComp_
#include <algorithm>
#include <array>
#include <utility>
#endif
#include <QString>
#include "UnitsSchemaMeterDecimal.h"
using namespace Base;
QString UnitsSchemaMeterDecimal::schemaTranslate(const Base::Quantity& quant,
double& factor,
QString& unitString)
std::string UnitsSchemaMeterDecimal::schemaTranslate(const Base::Quantity& quant,
double& factor,
std::string& unitString)
{
Unit unit = quant.getUnit();
if (unit == Unit::Length) {
// all length units in metres
unitString = QString::fromLatin1("m");
factor = 1e3;
}
else if (unit == Unit::Area) {
// all area units in square meters
unitString = QString::fromLatin1("m^2");
factor = 1e6;
}
else if (unit == Unit::Volume) {
// all area units in cubic meters
unitString = QString::fromLatin1("m^3");
factor = 1e9;
}
else if (unit == Unit::Power) {
// watts
unitString = QString::fromLatin1("W");
factor = 1000000;
}
else if (unit == Unit::ElectricPotential) {
// volts
unitString = QString::fromLatin1("V");
factor = 1000000;
}
else if (unit == Unit::HeatFlux) {
// watts per square metre
unitString = QString::fromLatin1("W/m^2");
factor = 1.0;
}
else if (unit == Unit::Velocity) {
// metres per second
unitString = QString::fromLatin1("m/s");
factor = 1e3;
static std::array<std::pair<Unit, std::pair<std::string, double>>, 7> unitSpecs {{
{Unit::Length, {"m", 1e0}},
{Unit::Area, {"m^2", 1e6}},
{Unit::Volume, {"m^3", 1e9}},
{Unit::Power, {"W", 1000000}},
{Unit::ElectricPotential, {"V", 1000000}},
{Unit::HeatFlux, {"W/m^2", 1.0}},
{Unit::Velocity, {"m/s", 1e3}},
}};
const auto unit = quant.getUnit();
const auto spec = std::find_if(unitSpecs.begin(), unitSpecs.end(), [&](const auto& pair) {
return pair.first == unit;
});
if (spec != std::end(unitSpecs)) {
unitString = spec->second.first;
factor = spec->second.second;
}
else {
// default action for all cases without special treatment:
unitString = quant.getUnit().getString();
factor = 1.0;
}
+2 -4
View File
@@ -29,10 +29,8 @@
#ifndef BASE_UNITSSCHEMAMETERS_H
#define BASE_UNITSSCHEMAMETERS_H
#include <QString>
#include "UnitsSchema.h"
namespace Base
{
@@ -42,8 +40,8 @@ namespace Base
class UnitsSchemaMeterDecimal: public UnitsSchema
{
public:
QString
schemaTranslate(const Base::Quantity& quant, double& factor, QString& unitString) override;
std::string
schemaTranslate(const Base::Quantity& quant, double& factor, std::string& unitString) override;
std::string getBasicLengthUnit() const override
{
+20 -21
View File
@@ -22,36 +22,35 @@
#include "PreCompiled.h"
#ifdef __GNUC__
#include <unistd.h>
#ifndef _PreComp_
#include <algorithm>
#include <array>
#include <utility>
#endif
#include <QString>
#include "UnitsSchemaMmMin.h"
using namespace Base;
QString
UnitsSchemaMmMin::schemaTranslate(const Quantity& quant, double& factor, QString& unitString)
std::string
UnitsSchemaMmMin::schemaTranslate(const Quantity& quant, double& factor, std::string& unitString)
{
Unit unit = quant.getUnit();
if (unit == Unit::Length) {
unitString = QString::fromLatin1("mm");
factor = 1.0;
}
else if (unit == Unit::Angle) {
unitString = QString::fromUtf8("\xC2\xB0");
factor = 1.0;
}
else if (unit == Unit::Velocity) {
unitString = QString::fromLatin1("mm/min");
factor = 1. / 60.;
static std::array<std::pair<Unit, std::pair<std::string, double>>, 3> unitSpecs {{
{Unit::Length, {"mm", 1.0}},
{Unit::Angle, {"\xC2\xB0", 1.0}},
{Unit::Velocity, {"mm/min", 1.0 / 60.0}},
}};
const auto unit = quant.getUnit();
const auto spec = std::find_if(unitSpecs.begin(), unitSpecs.end(), [&](const auto& pair) {
return pair.first == unit;
});
if (spec != std::end(unitSpecs)) {
unitString = spec->second.first;
factor = spec->second.second;
}
else {
// default action for all cases without special treatment:
unitString = quant.getUnit().getString();
factor = 1.0;
}
+2 -8
View File
@@ -20,18 +20,14 @@
* *
***************************************************************************/
#ifndef BASE_UNITSSCHEMAMMMIN_H
#define BASE_UNITSSCHEMAMMMIN_H
#include <QString>
#include "UnitsSchema.h"
namespace Base
{
/* Metric units schema intended for design of small parts and for CNC
* Lengths are always in mm.
* Angles in degrees (use degree symbol)
@@ -40,12 +36,10 @@ namespace Base
class UnitsSchemaMmMin: public UnitsSchema
{
public:
QString
schemaTranslate(const Base::Quantity& quant, double& factor, QString& unitString) override;
std::string
schemaTranslate(const Base::Quantity& quant, double& factor, std::string& unitString) override;
};
} // namespace Base
#endif // BASE_UNITSSCHEMAMMMIN_H
+5 -5
View File
@@ -5,14 +5,14 @@ The FreeCAD Document Object
:maxdepth: 4
.. automodule:: DocumentObject
.. autoclass:: DocumentObject
:members:
.. method:: __setstate__(value)
allows to save custom attributes of this object as strings, so they can be saved when saving the FreeCAD document
.. method:: __getstate__()
reads values previously saved with __setstate__()
+1 -1
View File
@@ -3,7 +3,7 @@ The Matrix object
.. toctree::
:maxdepth: 4
.. automodule:: FreeCAD
.. autoclass:: Matrix
+1 -1
View File
@@ -3,7 +3,7 @@ The Placement object
.. toctree::
:maxdepth: 4
.. automodule:: FreeCAD
.. autoclass:: Placement
+1 -1
View File
@@ -3,7 +3,7 @@ The Vector object
.. toctree::
:maxdepth: 4
.. automodule:: FreeCAD
.. autoclass:: Vector
@@ -161,5 +161,7 @@ private:
mutable std::array<SbVec2f, hitTestingResolution> hitTestPattern;
mutable bool patternInitialized;
std::vector<std::string> exportedCommandSets;
mutable bool wasPointerPick = false;
double orthoNearDistance = 0.0;
};
#endif
+17 -32
View File
@@ -101,11 +101,16 @@ long NavlibInterface::GetPointerPosition(navlib::point_t& position) const
QPoint viewPoint = currentView.pView3d->mapFromGlobal(QCursor::pos());
viewPoint.setY(currentView.pView3d->height() - viewPoint.y());
double scaling = inventorViewer->devicePixelRatio();
viewPoint *= scaling;
SbVec3f worldPosition =
inventorViewer->getPointOnFocalPlane(SbVec2s(viewPoint.x(), viewPoint.y()));
std::copy(worldPosition.getValue(), worldPosition.getValue() + 3, &position.x);
wasPointerPick = true;
return 0;
}
return navlib::make_result_code(navlib::navlib_errc::no_data_available);
@@ -272,34 +277,8 @@ long NavlibInterface::SetCameraMatrix(const navlib::matrix_t& matrix)
pCamera->orientation = SbRotation(cameraMatrix);
pCamera->position.setValue(matrix(3, 0), matrix(3, 1), matrix(3, 2));
const Gui::View3DInventorViewer* inventorViewer = currentView.pView3d->getViewer();
SoGetBoundingBoxAction action(inventorViewer->getSoRenderManager()->getViewportRegion());
action.apply(inventorViewer->getSceneGraph());
const SbBox3f boundingBox = action.getBoundingBox();
SbVec3f modelCenter = boundingBox.getCenter();
const float modelRadius = (boundingBox.getMin() - modelCenter).length();
navlib::bool_t isPerspective;
GetIsViewPerspective(isPerspective);
if (!isPerspective) {
cameraMatrix.inverse().multVecMatrix(modelCenter, modelCenter);
const float nearDist = -(modelRadius + modelCenter.getValue()[2]);
const float farDist = nearDist + 2.0f * modelRadius;
if (nearDist < 0.0f) {
pCamera->nearDistance.setValue(nearDist);
pCamera->farDistance.setValue(-nearDist);
}
else {
pCamera->nearDistance.setValue(-farDist);
pCamera->farDistance.setValue(farDist);
}
}
pCamera->touch();
return 0;
}
return navlib::make_result_code(navlib::navlib_errc::no_data_available);
@@ -351,11 +330,16 @@ long NavlibInterface::GetViewExtents(navlib::box_t& extents) const
return navlib::make_result_code(navlib::navlib_errc::no_data_available);
const SbViewVolume viewVolume = pCamera->getViewVolume(pCamera->aspectRatio.getValue());
const float halfHeight = viewVolume.getHeight() / 2.0f;
const float halfWidth = viewVolume.getWidth() / 2.0f;
const float farDistance = viewVolume.nearToFar + viewVolume.nearDist;
const double halfHeight = static_cast<double>(viewVolume.getHeight() / 2.0f);
const double halfWidth = static_cast<double>(viewVolume.getWidth() / 2.0f);
const double halfDepth = 1.0e8;
extents = {-halfWidth, -halfHeight, -farDistance, halfWidth, halfHeight, farDistance};
extents = {-halfWidth,
-halfHeight,
-halfDepth,
halfWidth,
halfHeight,
halfDepth};
return 0;
}
@@ -393,6 +377,7 @@ long NavlibInterface::SetViewExtents(const navlib::box_t& extents)
GetViewExtents(oldExtents);
pCamera->scaleHeight(extents.max.x / oldExtents.max.x);
orthoNearDistance = pCamera->nearDistance.getValue();
return 0;
}
+52 -11
View File
@@ -138,29 +138,50 @@ long NavlibInterface::GetHitLookAt(navlib::point_t& position) const
pCamera->orientation.getValue().getValue(cameraMatrix);
// Initialize the samples array if it wasn't done before
// Initialize the samples array if it wasn't done before
initializePattern();
navlib::bool_t isPerspective;
GetIsViewPerspective(isPerspective);
for (uint32_t i = 0; i < hitTestingResolution; i++) {
// Scale the sample like it was defined in camera space (placed on XY plane)
SbVec3f transform(
hitTestPattern[i][0] * ray.radius, hitTestPattern[i][1] * ray.radius, 0.0f);
// Apply the model-view transform to a sample (only the rotation)
cameraMatrix.multVecMatrix(transform, transform);
SbVec3f origin;
// Calculate origin of current hit-testing ray
SbVec3f newOrigin = ray.origin + transform;
if (wasPointerPick) {
origin = ray.origin;
}
else {
// Scale the sample like it was defined in camera space (placed on XY plane)
SbVec3f transform(hitTestPattern[i][0] * ray.radius,
hitTestPattern[i][1] * ray.radius,
0.0f);
// Apply the model-view transform to a sample (only the rotation)
cameraMatrix.multVecMatrix(transform, transform);
// Calculate origin of current hit-testing ray
origin = ray.origin + transform;
}
// Perform the hit-test
rayPickAction.setRay(newOrigin, ray.direction);
if (isPerspective) {
rayPickAction.setRay(origin,
ray.direction,
pCamera->nearDistance.getValue(),
pCamera->farDistance.getValue());
}
else {
rayPickAction.setRay(origin, ray.direction);
}
rayPickAction.apply(pSceneGraph);
SoPickedPoint* pickedPoint = rayPickAction.getPickedPoint();
// Check if there was a hit
if (pickedPoint != nullptr) {
SbVec3f hitPoint = pickedPoint->getPoint();
float distance = (newOrigin - hitPoint).length();
float distance = (origin - hitPoint).length();
// Save hit of the lowest depth
if (distance < minLength) {
@@ -168,6 +189,11 @@ long NavlibInterface::GetHitLookAt(navlib::point_t& position) const
closestHitPoint = hitPoint;
}
}
if (wasPointerPick) {
wasPointerPick = false;
break;
}
}
if (minLength < MAX_FLOAT) {
@@ -221,7 +247,22 @@ long NavlibInterface::SetHitDirection(const navlib::vector_t& direction)
long NavlibInterface::SetHitLookFrom(const navlib::point_t& eye)
{
ray.origin.setValue(eye.x, eye.y, eye.z);
navlib::bool_t isPerspective;
GetIsViewPerspective(isPerspective);
if (isPerspective) {
ray.origin.setValue(eye.x, eye.y, eye.z);
}
else {
auto pCamera = getCamera<SoCamera*>();
if (pCamera == nullptr) {
return navlib::make_result_code(navlib::navlib_errc::no_data_available);
}
SbVec3f position = pCamera->position.getValue();
ray.origin = position + orthoNearDistance * ray.direction;
}
return 0;
}
+23 -2
View File
@@ -848,6 +848,25 @@ void RecentFilesAction::appendFile(const QString& filename)
_pimpl->trySaveUserParameter();
}
static QString numberToLabel(int number) {
if (number > 0 && number < 10) { // NOLINT: *-magic-numbers
return QString::fromLatin1("&%1").arg(number);
}
if (number == 10) { // NOLINT: *-magic-numbers
return QString::fromLatin1("1&0");
}
// If we have a number greater than 10, we start using the alphabet.
// So 11 becomes 'A' and so on.
constexpr char lettersStart = 11;
constexpr char lettersEnd = lettersStart + ('Z' - 'A');
if (number >= lettersStart && number < lettersEnd) {
QChar letter = QChar::fromLatin1('A' + (number - lettersStart));
return QString::fromLatin1("%1 (&%2)").arg(number).arg(letter);
}
// Not enough accelerators to cover this number.
return QString::fromLatin1("%1").arg(number);
}
/**
* Set the list of recent files. For each item an action object is
* created and added to this action group.
@@ -858,8 +877,9 @@ void RecentFilesAction::setFiles(const QStringList& files)
int numRecentFiles = std::min<int>(recentFiles.count(), files.count());
for (int index = 0; index < numRecentFiles; index++) {
QString numberLabel = numberToLabel(index + 1);
QFileInfo fi(files[index]);
recentFiles[index]->setText(QString::fromLatin1("%1 %2").arg(index+1).arg(fi.fileName()));
recentFiles[index]->setText(QString::fromLatin1("%1 %2").arg(numberLabel).arg(fi.fileName()));
recentFiles[index]->setStatusTip(tr("Open file %1").arg(files[index]));
recentFiles[index]->setToolTip(files[index]); // set the full name that we need later for saving
recentFiles[index]->setData(QVariant(index));
@@ -1020,7 +1040,8 @@ void RecentMacrosAction::setFiles(const QStringList& files)
auto accel_col = QString::fromStdString(shortcut_modifiers);
for (int index = 0; index < numRecentFiles; index++) {
QFileInfo fi(files[index]);
recentFiles[index]->setText(QString::fromLatin1("%1 %2").arg(index+1).arg(fi.completeBaseName()));
QString numberLabel = numberToLabel(index + 1);
recentFiles[index]->setText(QString::fromLatin1("%1 %2").arg(numberLabel).arg(fi.completeBaseName()));
recentFiles[index]->setToolTip(files[index]); // set the full name that we need later for saving
recentFiles[index]->setData(QVariant(index));
QString accel(tr("none"));
+7 -2
View File
@@ -60,6 +60,7 @@
#include <Quarter/Quarter.h>
#include "Application.h"
#include "ApplicationPy.h"
#include "AxisOriginPy.h"
#include "BitmapFactory.h"
#include "Command.h"
@@ -436,7 +437,7 @@ Application::Application(bool GUIenabled)
"FreeCADGui",
FreeCADGui_doc,
-1,
Application::Methods,
ApplicationPy::Methods,
nullptr,
nullptr,
nullptr,
@@ -447,7 +448,7 @@ Application::Application(bool GUIenabled)
}
else {
// extend the method list
PyModule_AddFunctions(module, Application::Methods);
PyModule_AddFunctions(module, ApplicationPy::Methods);
}
Py::Module(module).setAttr(std::string("ActiveDocument"), Py::None());
Py::Module(module).setAttr(std::string("HasQtBug_129596"),
@@ -2282,6 +2283,10 @@ void Application::runApplication()
MainWindow mw;
mw.setProperty("QuitOnClosed", true);
// https://forum.freecad.org/viewtopic.php?f=3&t=15540
// Needs to be set after app is created to override platform defaults (qt commit a2aa1f81a81)
QApplication::setAttribute(Qt::AA_DontShowIconsInMenus, false);
#ifdef FC_DEBUG // redirect Coin messages to FreeCAD
SoDebugError::setHandlerCallback(messageHandlerCoin, 0);
#endif
+8 -82
View File
@@ -39,6 +39,7 @@ class SoNode;
class NavlibInterface;
namespace Gui{
class ApplicationPy;
class BaseView;
class CommandManager;
class Document;
@@ -263,22 +264,22 @@ protected:
const std::map<int, std::pair<std::string, std::string>> userEditModes {
{0,
std::make_pair(
QT_TRANSLATE_NOOP("EditMode", "Default"),
QT_TRANSLATE_NOOP("EditMode", "&Default"),
QT_TRANSLATE_NOOP("EditMode",
"The object will be edited using the mode defined internally to be "
"the most appropriate for the object type"))},
{1,
std::make_pair(QT_TRANSLATE_NOOP("EditMode", "Transform"),
std::make_pair(QT_TRANSLATE_NOOP("EditMode", "Trans&form"),
QT_TRANSLATE_NOOP("EditMode",
"The object will have its placement editable with the "
"Std TransformManip command"))},
{2,
std::make_pair(QT_TRANSLATE_NOOP("EditMode", "Cutting"),
std::make_pair(QT_TRANSLATE_NOOP("EditMode", "Cu&tting"),
QT_TRANSLATE_NOOP("EditMode",
"This edit mode is implemented as available but "
"currently does not seem to be used by any object"))},
{3,
std::make_pair(QT_TRANSLATE_NOOP("EditMode", "Color"),
std::make_pair(QT_TRANSLATE_NOOP("EditMode", "&Color"),
QT_TRANSLATE_NOOP("EditMode",
"The object will have the color of its individual faces "
"editable with the Part FaceAppearances command"))},
@@ -293,88 +294,13 @@ public:
bool setUserEditMode(const std::string &mode);
//@}
public:
//---------------------------------------------------------------------
// python exports goes here +++++++++++++++++++++++++++++++++++++++++++
//---------------------------------------------------------------------
// static python wrapper of the exported functions
static PyObject* sActivateWorkbenchHandler (PyObject *self,PyObject *args); // activates a workbench object
static PyObject* sAddWorkbenchHandler (PyObject *self,PyObject *args); // adds a new workbench handler to a list
static PyObject* sRemoveWorkbenchHandler (PyObject *self,PyObject *args); // removes a workbench handler from the list
static PyObject* sGetWorkbenchHandler (PyObject *self,PyObject *args); // retrieves the workbench handler
static PyObject* sListWorkbenchHandlers (PyObject *self,PyObject *args); // retrieves a list of all workbench handlers
static PyObject* sActiveWorkbenchHandler (PyObject *self,PyObject *args); // retrieves the active workbench object
static PyObject* sAddResPath (PyObject *self,PyObject *args); // adds a path where to find resources
static PyObject* sAddLangPath (PyObject *self,PyObject *args); // adds a path to a qm file
static PyObject* sAddIconPath (PyObject *self,PyObject *args); // adds a path to an icon file
static PyObject* sAddIcon (PyObject *self,PyObject *args); // adds an icon to the cache
static PyObject* sGetIcon (PyObject *self,PyObject *args); // get an icon from the cache
static PyObject* sIsIconCached (PyObject *self,PyObject *args); // check if an icon is cached
static PyObject* sSendActiveView (PyObject *self,PyObject *args);
static PyObject* sSendFocusView (PyObject *self,PyObject *args);
static PyObject* sGetMainWindow (PyObject *self,PyObject *args);
static PyObject* sUpdateGui (PyObject *self,PyObject *args);
static PyObject* sUpdateLocale (PyObject *self,PyObject *args);
static PyObject* sGetLocale (PyObject *self,PyObject *args);
static PyObject* sSetLocale (PyObject *self,PyObject *args);
static PyObject* sSupportedLocales (PyObject *self,PyObject *args);
static PyObject* sCreateDialog (PyObject *self,PyObject *args);
static PyObject* sAddPreferencePage (PyObject *self,PyObject *args);
static PyObject* sRunCommand (PyObject *self,PyObject *args);
static PyObject* sAddCommand (PyObject *self,PyObject *args);
static PyObject* sHide (PyObject *self,PyObject *args); // deprecated
static PyObject* sShow (PyObject *self,PyObject *args); // deprecated
static PyObject* sHideObject (PyObject *self,PyObject *args); // hide view provider object
static PyObject* sShowObject (PyObject *self,PyObject *args); // show view provider object
static PyObject* sOpen (PyObject *self,PyObject *args); // open Python scripts
static PyObject* sInsert (PyObject *self,PyObject *args); // open Python scripts
static PyObject* sExport (PyObject *self,PyObject *args);
static PyObject* sReload (PyObject *self,PyObject *args); // reload FCStd file
static PyObject* sLoadFile (PyObject *self,PyObject *args); // open all types of files
static PyObject* sCoinRemoveAllChildren (PyObject *self,PyObject *args);
static PyObject* sActiveDocument (PyObject *self,PyObject *args);
static PyObject* sSetActiveDocument (PyObject *self,PyObject *args);
static PyObject* sActiveView (PyObject *self,PyObject *args);
static PyObject* sActivateView (PyObject *self,PyObject *args);
static PyObject* sGetDocument (PyObject *self,PyObject *args);
static PyObject* sEditDocument (PyObject *self,PyObject *args);
static PyObject* sDoCommand (PyObject *self,PyObject *args);
static PyObject* sDoCommandGui (PyObject *self,PyObject *args);
static PyObject* sDoCommandEval (PyObject *self,PyObject *args);
static PyObject* sDoCommandSkip (PyObject *self,PyObject *args);
static PyObject* sAddModule (PyObject *self,PyObject *args);
static PyObject* sShowDownloads (PyObject *self,PyObject *args);
static PyObject* sShowPreferences (PyObject *self,PyObject *args);
static PyObject* sCreateViewer (PyObject *self,PyObject *args);
static PyObject* sGetMarkerIndex (PyObject *self,PyObject *args);
static PyObject* sAddDocObserver (PyObject *self,PyObject *args);
static PyObject* sRemoveDocObserver (PyObject *self,PyObject *args);
static PyObject* sAddWbManipulator (PyObject *self,PyObject *args);
static PyObject* sRemoveWbManipulator (PyObject *self,PyObject *args);
static PyObject* sListUserEditModes (PyObject *self,PyObject *args);
static PyObject* sGetUserEditMode (PyObject *self,PyObject *args);
static PyObject* sSetUserEditMode (PyObject *self,PyObject *args);
static PyMethodDef Methods[];
private:
struct ApplicationP* d;
/// workbench python dictionary
PyObject* _pcWorkbenchDictionary;
PyObject* _pcWorkbenchDictionary;
NavlibInterface* pNavlibInterface;
friend class ApplicationPy;
};
} //namespace Gui
+418 -291
View File
File diff suppressed because it is too large Load Diff
+120
View File
@@ -0,0 +1,120 @@
/***************************************************************************
* Copyright (c) 2004 Jürgen Riegel <juergen.riegel@web.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library 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 library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef GUI_APPLICATIONPY_H
#define GUI_APPLICATIONPY_H
#include <Base/PyObjectBase.h>
namespace Gui{
/** The ApplicationPy class
* This is the Python wrapper class of Application.
* @author Jürgen Riegel, Werner Mayer
*/
class GuiExport ApplicationPy
{
public:
// clang-format off
//---------------------------------------------------------------------
// python exports goes here +++++++++++++++++++++++++++++++++++++++++++
//---------------------------------------------------------------------
// static python wrapper of the exported functions
static PyObject* sActivateWorkbenchHandler (PyObject *self,PyObject *args); // activates a workbench object
static PyObject* sAddWorkbenchHandler (PyObject *self,PyObject *args); // adds a new workbench handler to a list
static PyObject* sRemoveWorkbenchHandler (PyObject *self,PyObject *args); // removes a workbench handler from the list
static PyObject* sGetWorkbenchHandler (PyObject *self,PyObject *args); // retrieves the workbench handler
static PyObject* sListWorkbenchHandlers (PyObject *self,PyObject *args); // retrieves a list of all workbench handlers
static PyObject* sActiveWorkbenchHandler (PyObject *self,PyObject *args); // retrieves the active workbench object
static PyObject* sAddResPath (PyObject *self,PyObject *args); // adds a path where to find resources
static PyObject* sAddLangPath (PyObject *self,PyObject *args); // adds a path to a qm file
static PyObject* sAddIconPath (PyObject *self,PyObject *args); // adds a path to an icon file
static PyObject* sAddIcon (PyObject *self,PyObject *args); // adds an icon to the cache
static PyObject* sGetIcon (PyObject *self,PyObject *args); // get an icon from the cache
static PyObject* sIsIconCached (PyObject *self,PyObject *args); // check if an icon is cached
static PyObject* sSendActiveView (PyObject *self,PyObject *args);
static PyObject* sSendFocusView (PyObject *self,PyObject *args);
static PyObject* sGetMainWindow (PyObject *self,PyObject *args);
static PyObject* sUpdateGui (PyObject *self,PyObject *args);
static PyObject* sUpdateLocale (PyObject *self,PyObject *args);
static PyObject* sGetLocale (PyObject *self,PyObject *args);
static PyObject* sSetLocale (PyObject *self,PyObject *args);
static PyObject* sSupportedLocales (PyObject *self,PyObject *args);
static PyObject* sCreateDialog (PyObject *self,PyObject *args);
static PyObject* sAddPreferencePage (PyObject *self,PyObject *args);
static PyObject* sRunCommand (PyObject *self,PyObject *args);
static PyObject* sAddCommand (PyObject *self,PyObject *args);
static PyObject* sHide (PyObject *self,PyObject *args); // deprecated
static PyObject* sShow (PyObject *self,PyObject *args); // deprecated
static PyObject* sHideObject (PyObject *self,PyObject *args); // hide view provider object
static PyObject* sShowObject (PyObject *self,PyObject *args); // show view provider object
static PyObject* sOpen (PyObject *self,PyObject *args); // open Python scripts
static PyObject* sInsert (PyObject *self,PyObject *args); // open Python scripts
static PyObject* sExport (PyObject *self,PyObject *args);
static PyObject* sReload (PyObject *self,PyObject *args); // reload FCStd file
static PyObject* sLoadFile (PyObject *self,PyObject *args); // open all types of files
static PyObject* sCoinRemoveAllChildren (PyObject *self,PyObject *args);
static PyObject* sActiveDocument (PyObject *self,PyObject *args);
static PyObject* sSetActiveDocument (PyObject *self,PyObject *args);
static PyObject* sActiveView (PyObject *self,PyObject *args);
static PyObject* sActivateView (PyObject *self,PyObject *args);
static PyObject* sGetDocument (PyObject *self,PyObject *args);
static PyObject* sEditDocument (PyObject *self,PyObject *args);
static PyObject* sDoCommand (PyObject *self,PyObject *args);
static PyObject* sDoCommandGui (PyObject *self,PyObject *args);
static PyObject* sDoCommandEval (PyObject *self,PyObject *args);
static PyObject* sDoCommandSkip (PyObject *self,PyObject *args);
static PyObject* sAddModule (PyObject *self,PyObject *args);
static PyObject* sShowDownloads (PyObject *self,PyObject *args);
static PyObject* sShowPreferences (PyObject *self,PyObject *args);
static PyObject* sShowPreferencesByName (PyObject *self,PyObject *args);
static PyObject* sCreateViewer (PyObject *self,PyObject *args);
static PyObject* sGetMarkerIndex (PyObject *self,PyObject *args);
static PyObject* sAddDocObserver (PyObject *self,PyObject *args);
static PyObject* sRemoveDocObserver (PyObject *self,PyObject *args);
static PyObject* sAddWbManipulator (PyObject *self,PyObject *args);
static PyObject* sRemoveWbManipulator (PyObject *self,PyObject *args);
static PyObject* sListUserEditModes (PyObject *self,PyObject *args);
static PyObject* sGetUserEditMode (PyObject *self,PyObject *args);
static PyObject* sSetUserEditMode (PyObject *self,PyObject *args);
static PyMethodDef Methods[];
// clang-format on
};
} //namespace Gui
#endif
+7 -2
View File
@@ -197,13 +197,11 @@ SbBool BlenderNavigationStyle::processSoEvent(const SoEvent * const ev)
const auto * const event = (const SoLocation2Event *) ev;
if (this->currentmode == NavigationStyle::ZOOMING) {
this->zoomByCursor(posn, prevnormalized);
newmode = NavigationStyle::SELECTION;
processed = true;
}
else if (this->currentmode == NavigationStyle::PANNING) {
float ratio = vp.getViewportAspectRatio();
panCamera(viewer->getSoRenderManager()->getCamera(), ratio, this->panningplane, posn, prevnormalized);
newmode = NavigationStyle::SELECTION;
processed = true;
}
else if (this->currentmode == NavigationStyle::DRAGGING) {
@@ -277,6 +275,13 @@ SbBool BlenderNavigationStyle::processSoEvent(const SoEvent * const ev)
break;
default:
// Reset mode to IDLE when button 3 is released
// This stops the PANNING when button 3 is released but SHIFT is still pressed
// This stops the ZOOMING when button 3 is released but CTRL is still pressed
if ((curmode == NavigationStyle::PANNING || curmode == NavigationStyle::ZOOMING)
&& !this->button3down) {
newmode = NavigationStyle::IDLE;
}
break;
}
+2
View File
@@ -1066,6 +1066,7 @@ SET(Inventor_CPP_SRCS
SoFCSelectionAction.cpp
SoFCVectorizeSVGAction.cpp
SoFCVectorizeU3DAction.cpp
SoDevicePixelRatioElement.cpp
SoTextLabel.cpp
SoDatumLabel.cpp
SoTouchEvents.cpp
@@ -1097,6 +1098,7 @@ SET(Inventor_SRCS
SoFCSelectionAction.h
SoFCVectorizeSVGAction.h
SoFCVectorizeU3DAction.h
SoDevicePixelRatioElement.h
SoTextLabel.h
SoDatumLabel.h
SoTouchEvents.h
+74 -28
View File
@@ -25,6 +25,7 @@
#ifndef _PreComp_
# include <Inventor/nodes/SoCamera.h>
# include <QApplication>
# include <QCheckBox>
# include <QClipboard>
# include <QDateTime>
# include <QMessageBox>
@@ -95,6 +96,56 @@ StdCmdOpen::StdCmdOpen()
void StdCmdOpen::activated(int iMsg)
{
// clang-format off
auto checkPartialRestore = [](App::Document* doc) {
if (doc && doc->testStatus(App::Document::PartialRestore)) {
QMessageBox::critical(getMainWindow(), QObject::tr("Error"),
QObject::tr("There were errors while loading the file. Some data might have been "
"modified or not recovered at all. Look in the report view for more "
"specific information about the objects involved."));
}
};
auto checkRestoreError = [](App::Document* doc) {
if (doc && doc->testStatus(App::Document::RestoreError)) {
QMessageBox::critical(getMainWindow(), QObject::tr("Error"),
QObject::tr("There were serious errors while loading the file. Some data might have "
"been modified or not recovered at all. Saving the project will most "
"likely result in loss of data."));
}
};
auto checkMigrationLCS = [](App::Document* doc) {
if (doc && doc->testStatus(App::Document::MigrateLCS)) {
auto grp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View");
if (!grp->GetBool("ShowLCSMigrationWarning", true)) {
return;
}
// Display the warning message
QMessageBox msgBox(QMessageBox::Warning,
QObject::tr("File Migration Warning"),
QObject::tr("This file was created with an older version of %1. "
"Origin axes had incorrect placements, which have now been corrected.\n\n"
"However, if you save this file in the current version and reopen it in an"
" older version of %1, the origin axes will be misaligned. Additionally, "
"if your file references these origin axes, your file will likely be broken.")
.arg(QApplication::applicationName()),
QMessageBox::Ok);
QCheckBox* checkBox = new QCheckBox(QObject::tr("Don't show this warning again"));
msgBox.setCheckBox(checkBox);
msgBox.exec();
// Save preference if the user selects "Don't show again"
if (checkBox->isChecked()) {
grp->SetBool("ShowLCSMigrationWarning", false);
}
}
};
// clang-format on
Q_UNUSED(iMsg);
// fill the list of registered endings
@@ -139,8 +190,9 @@ void StdCmdOpen::activated(int iMsg)
QString selectedFilter;
QStringList fileList = FileDialog::getOpenFileNames(getMainWindow(),
QObject::tr("Open document"), QString(), formatList, &selectedFilter);
if (fileList.isEmpty())
if (fileList.isEmpty()) {
return;
}
// load the files with the associated modules
SelectModule::Dict dict = SelectModule::importHandler(fileList, selectedFilter);
@@ -161,15 +213,9 @@ void StdCmdOpen::activated(int iMsg)
App::Document *doc = App::GetApplication().getActiveDocument();
if(doc && doc->testStatus(App::Document::PartialRestore)) {
QMessageBox::critical(getMainWindow(), QObject::tr("Error"),
QObject::tr("There were errors while loading the file. Some data might have been modified or not recovered at all. Look in the report view for more specific information about the objects involved."));
}
if(doc && doc->testStatus(App::Document::RestoreError)) {
QMessageBox::critical(getMainWindow(), QObject::tr("Error"),
QObject::tr("There were serious errors while loading the file. Some data might have been modified or not recovered at all. Saving the project will most likely result in loss of data."));
}
checkPartialRestore(doc);
checkRestoreError(doc);
checkMigrationLCS(doc);
}
}
}
@@ -521,7 +567,7 @@ StdCmdMergeProjects::StdCmdMergeProjects()
{
sAppModule = "File";
sGroup = "File";
sMenuText = QT_TR_NOOP("Merge document...");
sMenuText = QT_TR_NOOP("&Merge document...");
sToolTipText = QT_TR_NOOP("Merge document");
sWhatsThis = "Std_MergeProjects";
sStatusTip = QT_TR_NOOP("Merge document");
@@ -574,7 +620,7 @@ StdCmdDependencyGraph::StdCmdDependencyGraph()
{
// setting the
sGroup = "Tools";
sMenuText = QT_TR_NOOP("Dependency graph...");
sMenuText = QT_TR_NOOP("Dependency gra&ph...");
sToolTipText = QT_TR_NOOP("Show the dependency graph of the objects in the active document");
sStatusTip = QT_TR_NOOP("Show the dependency graph of the objects in the active document");
sWhatsThis = "Std_DependencyGraph";
@@ -606,7 +652,7 @@ StdCmdExportDependencyGraph::StdCmdExportDependencyGraph()
: Command("Std_ExportDependencyGraph")
{
sGroup = "Tools";
sMenuText = QT_TR_NOOP("Export dependency graph...");
sMenuText = QT_TR_NOOP("Export dependency &graph...");
sToolTipText = QT_TR_NOOP("Export the dependency graph to a file");
sStatusTip = QT_TR_NOOP("Export the dependency graph to a file");
sWhatsThis = "Std_ExportDependencyGraph";
@@ -735,7 +781,7 @@ StdCmdSaveCopy::StdCmdSaveCopy()
:Command("Std_SaveCopy")
{
sGroup = "File";
sMenuText = QT_TR_NOOP("Save a &Copy...");
sMenuText = QT_TR_NOOP("Save a Cop&y...");
sToolTipText = QT_TR_NOOP("Save a copy of the active document under a new file name");
sWhatsThis = "Std_SaveCopy";
sStatusTip = QT_TR_NOOP("Save a copy of the active document under a new file name");
@@ -762,7 +808,7 @@ StdCmdSaveAll::StdCmdSaveAll()
:Command("Std_SaveAll")
{
sGroup = "File";
sMenuText = QT_TR_NOOP("Save All");
sMenuText = QT_TR_NOOP("Sa&ve All");
sToolTipText = QT_TR_NOOP("Save all opened document");
sWhatsThis = "Std_SaveAll";
sStatusTip = QT_TR_NOOP("Save all opened document");
@@ -790,7 +836,7 @@ StdCmdRevert::StdCmdRevert()
:Command("Std_Revert")
{
sGroup = "File";
sMenuText = QT_TR_NOOP("Revert");
sMenuText = QT_TR_NOOP("Rever&t");
sToolTipText = QT_TR_NOOP("Reverts to the saved version of this file");
sWhatsThis = "Std_Revert";
sStatusTip = QT_TR_NOOP("Reverts to the saved version of this file");
@@ -829,7 +875,7 @@ StdCmdProjectInfo::StdCmdProjectInfo()
{
// setting the
sGroup = "File";
sMenuText = QT_TR_NOOP("Document i&nformation...");
sMenuText = QT_TR_NOOP("Doc&ument information...");
sToolTipText = QT_TR_NOOP("Show details of the currently active document");
sWhatsThis = "Std_ProjectInfo";
sStatusTip = QT_TR_NOOP("Show details of the currently active document");
@@ -860,7 +906,7 @@ StdCmdProjectUtil::StdCmdProjectUtil()
// setting the
sGroup = "Tools";
sWhatsThis = "Std_ProjectUtil";
sMenuText = QT_TR_NOOP("Document utility...");
sMenuText = QT_TR_NOOP("Do&cument utility...");
sToolTipText = QT_TR_NOOP("Utility to extract or create document files");
sStatusTip = QT_TR_NOOP("Utility to extract or create document files");
sPixmap = "Std_ProjectUtil";
@@ -919,7 +965,7 @@ StdCmdPrintPreview::StdCmdPrintPreview()
:Command("Std_PrintPreview")
{
sGroup = "File";
sMenuText = QT_TR_NOOP("&Print preview...");
sMenuText = QT_TR_NOOP("Print previe&w...");
sToolTipText = QT_TR_NOOP("Print the document");
sWhatsThis = "Std_PrintPreview";
sStatusTip = QT_TR_NOOP("Print preview");
@@ -949,7 +995,7 @@ StdCmdPrintPdf::StdCmdPrintPdf()
:Command("Std_PrintPdf")
{
sGroup = "File";
sMenuText = QT_TR_NOOP("&Export PDF...");
sMenuText = QT_TR_NOOP("Export P&DF...");
sToolTipText = QT_TR_NOOP("Export the document as PDF");
sWhatsThis = "Std_PrintPdf";
sStatusTip = QT_TR_NOOP("Export the document as PDF");
@@ -1094,7 +1140,7 @@ StdCmdCut::StdCmdCut()
: Command("Std_Cut")
{
sGroup = "Edit";
sMenuText = QT_TR_NOOP("&Cut");
sMenuText = QT_TR_NOOP("Cu&t");
sToolTipText = QT_TR_NOOP("Cut out");
sWhatsThis = "Std_Cut";
sStatusTip = QT_TR_NOOP("Cut out");
@@ -1122,7 +1168,7 @@ StdCmdCopy::StdCmdCopy()
: Command("Std_Copy")
{
sGroup = "Edit";
sMenuText = QT_TR_NOOP("C&opy");
sMenuText = QT_TR_NOOP("&Copy");
sToolTipText = QT_TR_NOOP("Copy operation");
sWhatsThis = "Std_Copy";
sStatusTip = QT_TR_NOOP("Copy operation");
@@ -1197,7 +1243,7 @@ StdCmdDuplicateSelection::StdCmdDuplicateSelection()
{
sAppModule = "Edit";
sGroup = "Edit";
sMenuText = QT_TR_NOOP("Duplicate selection");
sMenuText = QT_TR_NOOP("Duplicate selecti&on");
sToolTipText = QT_TR_NOOP("Put duplicates of the selected objects to the active document");
sWhatsThis = "Std_DuplicateSelection";
sStatusTip = QT_TR_NOOP("Put duplicates of the selected objects to the active document");
@@ -1463,7 +1509,7 @@ StdCmdRefresh::StdCmdRefresh()
: Command("Std_Refresh")
{
sGroup = "Edit";
sMenuText = QT_TR_NOOP("&Refresh");
sMenuText = QT_TR_NOOP("Refres&h");
sToolTipText = QT_TR_NOOP("Recomputes the current active document");
sWhatsThis = "Std_Refresh";
sStatusTip = QT_TR_NOOP("Recomputes the current active document");
@@ -1543,7 +1589,7 @@ StdCmdPlacement::StdCmdPlacement()
: Command("Std_Placement")
{
sGroup = "Edit";
sMenuText = QT_TR_NOOP("Placement...");
sMenuText = QT_TR_NOOP("P&lacement...");
sToolTipText = QT_TR_NOOP("Place the selected objects");
sStatusTip = QT_TR_NOOP("Place the selected objects");
sWhatsThis = "Std_Placement";
@@ -1590,7 +1636,7 @@ StdCmdTransformManip::StdCmdTransformManip()
: Command("Std_TransformManip")
{
sGroup = "Edit";
sMenuText = QT_TR_NOOP("Transform");
sMenuText = QT_TR_NOOP("Trans&form");
sToolTipText = QT_TR_NOOP("Transform the selected object in the 3D view");
sStatusTip = QT_TR_NOOP("Transform the selected object in the 3D view");
sWhatsThis = "Std_TransformManip";
@@ -1625,7 +1671,7 @@ StdCmdAlignment::StdCmdAlignment()
: Command("Std_Alignment")
{
sGroup = "Edit";
sMenuText = QT_TR_NOOP("Alignment...");
sMenuText = QT_TR_NOOP("Ali&gnment...");
sToolTipText = QT_TR_NOOP("Align the selected objects");
sStatusTip = QT_TR_NOOP("Align the selected objects");
sWhatsThis = "Std_Alignment";
@@ -1735,7 +1781,7 @@ StdCmdProperties::StdCmdProperties()
: Command("Std_Properties")
{
sGroup = "Edit";
sMenuText = QT_TR_NOOP("Properties");
sMenuText = QT_TR_NOOP("Propert&ies");
sToolTipText = QT_TR_NOOP("Show the property view, which displays the properties of the selected object.");
sWhatsThis = "Std_Properties";
sStatusTip = sToolTipText;
+1 -1
View File
@@ -77,7 +77,7 @@ StdCmdRandomColor::StdCmdRandomColor()
:Command("Std_RandomColor")
{
sGroup = "File";
sMenuText = QT_TR_NOOP("Random color");
sMenuText = QT_TR_NOOP("Random &color");
sToolTipText = QT_TR_NOOP("Set each selected object to a randomly-selected color");
sWhatsThis = "Std_RandomColor";
sStatusTip = QT_TR_NOOP("Set each selected object to a randomly-selected color");
+5 -5
View File
@@ -646,7 +646,7 @@ StdCmdLinkSelectLinked::StdCmdLinkSelectLinked()
: Command("Std_LinkSelectLinked")
{
sGroup = "Link";
sMenuText = QT_TR_NOOP("Go to linked object");
sMenuText = QT_TR_NOOP("&Go to linked object");
sToolTipText = QT_TR_NOOP("Select the linked object and switch to its owner document");
sWhatsThis = "Std_LinkSelectLinked";
sStatusTip = sToolTipText;
@@ -774,7 +774,7 @@ StdCmdLinkSelectLinkedFinal::StdCmdLinkSelectLinkedFinal()
: Command("Std_LinkSelectLinkedFinal")
{
sGroup = "Link";
sMenuText = QT_TR_NOOP("Go to the deepest linked object");
sMenuText = QT_TR_NOOP("Go to the &deepest linked object");
sToolTipText = QT_TR_NOOP("Select the deepest linked object and switch to its owner document");
sWhatsThis = "Std_LinkSelectLinkedFinal";
sStatusTip = sToolTipText;
@@ -809,7 +809,7 @@ StdCmdLinkSelectAllLinks::StdCmdLinkSelectAllLinks()
: Command("Std_LinkSelectAllLinks")
{
sGroup = "Link";
sMenuText = QT_TR_NOOP("Select all links");
sMenuText = QT_TR_NOOP("Select &all links");
sToolTipText = QT_TR_NOOP("Select all links to the current selected object");
sWhatsThis = "Std_LinkSelectAllLinks";
sStatusTip = sToolTipText;
@@ -849,7 +849,7 @@ public:
: GroupCommand("Std_LinkSelectActions")
{
sGroup = "View";
sMenuText = QT_TR_NOOP("Link navigation");
sMenuText = QT_TR_NOOP("&Link navigation");
sToolTipText = QT_TR_NOOP("Link navigation actions");
sWhatsThis = "Std_LinkSelectActions";
sStatusTip = QT_TR_NOOP("Link navigation actions");
@@ -877,7 +877,7 @@ public:
sGroup = "View";
sMenuText = QT_TR_NOOP("Link actions");
sToolTipText = QT_TR_NOOP("Actions that apply to link objects");
sWhatsThis = "Std_LinkMakeRelative";
sWhatsThis = "Std_LinkActions";
sStatusTip = QT_TR_NOOP("Actions that apply to link objects");
eType = AlterDoc;
bCanLog = false;
+9 -9
View File
@@ -48,7 +48,7 @@ StdCmdDlgMacroRecord::StdCmdDlgMacroRecord()
: Command("Std_DlgMacroRecord")
{
sGroup = "Macro";
sMenuText = QT_TR_NOOP("&Macro recording ...");
sMenuText = QT_TR_NOOP("&Macro recording...");
sToolTipText = QT_TR_NOOP("Opens a dialog to record a macro");
sWhatsThis = "Std_DlgMacroRecord";
sStatusTip = QT_TR_NOOP("Opens a dialog to record a macro");
@@ -91,7 +91,7 @@ StdCmdDlgMacroExecute::StdCmdDlgMacroExecute()
: Command("Std_DlgMacroExecute")
{
sGroup = "Macro";
sMenuText = QT_TR_NOOP("Macros ...");
sMenuText = QT_TR_NOOP("Ma&cros...");
sToolTipText = QT_TR_NOOP("Opens a dialog to let you execute a recorded macro");
sWhatsThis = "Std_DlgMacroExecute";
sStatusTip = QT_TR_NOOP("Opens a dialog to let you execute a recorded macro");
@@ -120,7 +120,7 @@ StdCmdDlgMacroExecuteDirect::StdCmdDlgMacroExecuteDirect()
: Command("Std_DlgMacroExecuteDirect")
{
sGroup = "Macro";
sMenuText = QT_TR_NOOP("Execute macro");
sMenuText = QT_TR_NOOP("&Execute macro");
sToolTipText = QT_TR_NOOP("Execute the macro in the editor");
sWhatsThis = "Std_DlgMacroExecuteDirect";
sStatusTip = QT_TR_NOOP("Execute the macro in the editor");
@@ -146,7 +146,7 @@ StdCmdMacroAttachDebugger::StdCmdMacroAttachDebugger()
: Command("Std_MacroAttachDebugger")
{
sGroup = "Macro";
sMenuText = QT_TR_NOOP("Attach to remote debugger...");
sMenuText = QT_TR_NOOP("&Attach to remote debugger...");
sToolTipText = QT_TR_NOOP("Attach to a remotely running debugger");
sWhatsThis = "Std_MacroAttachDebugger";
sStatusTip = QT_TR_NOOP("Attach to a remotely running debugger");
@@ -171,7 +171,7 @@ StdCmdMacroStartDebug::StdCmdMacroStartDebug()
: Command("Std_MacroStartDebug")
{
sGroup = "Macro";
sMenuText = QT_TR_NOOP("Debug macro");
sMenuText = QT_TR_NOOP("&Debug macro");
sToolTipText = QT_TR_NOOP("Start debugging of macro");
sWhatsThis = "Std_MacroStartDebug";
sStatusTip = QT_TR_NOOP("Start debugging of macro");
@@ -201,7 +201,7 @@ StdCmdMacroStopDebug::StdCmdMacroStopDebug()
: Command("Std_MacroStopDebug")
{
sGroup = "Macro";
sMenuText = QT_TR_NOOP("Stop debugging");
sMenuText = QT_TR_NOOP("&Stop debugging");
sToolTipText = QT_TR_NOOP("Stop debugging of macro");
sWhatsThis = "Std_MacroStopDebug";
sStatusTip = QT_TR_NOOP("Stop debugging of macro");
@@ -228,7 +228,7 @@ StdCmdMacroStepOver::StdCmdMacroStepOver()
: Command("Std_MacroStepOver")
{
sGroup = "Macro";
sMenuText = QT_TR_NOOP("Step over");
sMenuText = QT_TR_NOOP("Step &over");
sToolTipText = QT_TR_NOOP("Step to the next line in this file");
sWhatsThis = "Std_MacroStepOver";
sStatusTip = QT_TR_NOOP("Step to the next line in this file");
@@ -255,7 +255,7 @@ StdCmdMacroStepInto::StdCmdMacroStepInto()
: Command("Std_MacroStepInto")
{
sGroup = "Macro";
sMenuText = QT_TR_NOOP("Step into");
sMenuText = QT_TR_NOOP("Step &into");
sToolTipText = QT_TR_NOOP("Step to the next line executed");
sWhatsThis = "Std_MacroStepInto";
sStatusTip = QT_TR_NOOP("Step to the next line executed");
@@ -282,7 +282,7 @@ StdCmdToggleBreakpoint::StdCmdToggleBreakpoint()
: Command("Std_ToggleBreakpoint")
{
sGroup = "Macro";
sMenuText = QT_TR_NOOP("Toggle breakpoint");
sMenuText = QT_TR_NOOP("Toggle &breakpoint");
sToolTipText = QT_TR_NOOP("Add or remove a breakpoint at this position");
sWhatsThis = "Std_ToggleBreakpoint";
sStatusTip = QT_TR_NOOP("Add or remove a breakpoint at this position");
+16 -16
View File
@@ -72,7 +72,7 @@ StdCmdWorkbench::StdCmdWorkbench()
: Command("Std_Workbench")
{
sGroup = "View";
sMenuText = QT_TR_NOOP("Workbench");
sMenuText = QT_TR_NOOP("&Workbench");
sToolTipText = QT_TR_NOOP("Switch between workbenches");
sWhatsThis = "Std_Workbench";
sStatusTip = QT_TR_NOOP("Switch between workbenches");
@@ -137,7 +137,7 @@ StdCmdRecentFiles::StdCmdRecentFiles()
:Command("Std_RecentFiles")
{
sGroup = "File";
sMenuText = QT_TR_NOOP("Open Recent");
sMenuText = QT_TR_NOOP("Open &Recent");
sToolTipText = QT_TR_NOOP("Recent file list");
sWhatsThis = "Std_RecentFiles";
sStatusTip = QT_TR_NOOP("Recent file list");
@@ -178,7 +178,7 @@ StdCmdRecentMacros::StdCmdRecentMacros()
:Command("Std_RecentMacros")
{
sGroup = "Macro";
sMenuText = QT_TR_NOOP("Recent macros");
sMenuText = QT_TR_NOOP("&Recent macros");
sToolTipText = QT_TR_NOOP("Recent macro list");
sWhatsThis = "Std_RecentMacros";
sStatusTip = QT_TR_NOOP("Recent macro list");
@@ -378,7 +378,7 @@ StdCmdDlgParameter::StdCmdDlgParameter()
:Command("Std_DlgParameter")
{
sGroup = "Tools";
sMenuText = QT_TR_NOOP("E&dit parameters ...");
sMenuText = QT_TR_NOOP("E&dit parameters...");
sToolTipText = QT_TR_NOOP("Opens a Dialog to edit the parameters");
sWhatsThis = "Std_DlgParameter";
sStatusTip = QT_TR_NOOP("Opens a Dialog to edit the parameters");
@@ -403,7 +403,7 @@ StdCmdDlgPreferences::StdCmdDlgPreferences()
:Command("Std_DlgPreferences")
{
sGroup = "Tools";
sMenuText = QT_TR_NOOP("&Preferences ...");
sMenuText = QT_TR_NOOP("Prefere&nces ...");
sToolTipText = QT_TR_NOOP("Opens a Dialog to edit the preferences");
sWhatsThis = "Std_DlgPreferences";
sStatusTip = QT_TR_NOOP("Opens a Dialog to edit the preferences");
@@ -522,7 +522,7 @@ StdCmdOnlineHelp::StdCmdOnlineHelp()
:Command("Std_OnlineHelp")
{
sGroup = "Help";
sMenuText = QT_TR_NOOP("Help");
sMenuText = QT_TR_NOOP("&Help");
sToolTipText = QT_TR_NOOP("Opens the Help documentation");
sWhatsThis = "Std_OnlineHelp";
sStatusTip = sToolTipText;
@@ -574,7 +574,7 @@ StdCmdFreeCADDonation::StdCmdFreeCADDonation()
:Command("Std_FreeCADDonation")
{
sGroup = "Help";
sMenuText = QT_TR_NOOP("Support FreeCAD");
sMenuText = QT_TR_NOOP("Support FreeCA&D");
sToolTipText = QT_TR_NOOP("Support FreeCAD development");
sWhatsThis = "Std_FreeCADDonation";
sStatusTip = sToolTipText;
@@ -601,7 +601,7 @@ StdCmdFreeCADWebsite::StdCmdFreeCADWebsite()
:Command("Std_FreeCADWebsite")
{
sGroup = "Help";
sMenuText = QT_TR_NOOP("FreeCAD Website");
sMenuText = QT_TR_NOOP("FreeCAD W&ebsite");
sToolTipText = QT_TR_NOOP("Navigates to the official FreeCAD website");
sWhatsThis = "Std_FreeCADWebsite";
sStatusTip = sToolTipText;
@@ -629,7 +629,7 @@ StdCmdFreeCADUserHub::StdCmdFreeCADUserHub()
:Command("Std_FreeCADUserHub")
{
sGroup = "Help";
sMenuText = QT_TR_NOOP("User Documentation");
sMenuText = QT_TR_NOOP("&User Documentation");
sToolTipText = QT_TR_NOOP("Opens the documentation for users");
sWhatsThis = "Std_FreeCADUserHub";
sStatusTip = sToolTipText;
@@ -657,7 +657,7 @@ StdCmdFreeCADPowerUserHub::StdCmdFreeCADPowerUserHub()
:Command("Std_FreeCADPowerUserHub")
{
sGroup = "Help";
sMenuText = QT_TR_NOOP("Python Scripting Documentation");
sMenuText = QT_TR_NOOP("&Python Scripting Documentation");
sToolTipText = QT_TR_NOOP("Opens the Python Scripting documentation");
sWhatsThis = "Std_FreeCADPowerUserHub";
sStatusTip = sToolTipText;
@@ -685,7 +685,7 @@ StdCmdFreeCADForum::StdCmdFreeCADForum()
:Command("Std_FreeCADForum")
{
sGroup = "Help";
sMenuText = QT_TR_NOOP("FreeCAD Forum");
sMenuText = QT_TR_NOOP("FreeCAD &Forum");
sToolTipText = QT_TR_NOOP("The FreeCAD forum, where you can find help from other users");
sWhatsThis = "Std_FreeCADForum";
sStatusTip = sToolTipText;
@@ -713,7 +713,7 @@ StdCmdFreeCADFAQ::StdCmdFreeCADFAQ()
:Command("Std_FreeCADFAQ")
{
sGroup = "Help";
sMenuText = QT_TR_NOOP("FreeCAD FAQ");
sMenuText = QT_TR_NOOP("FreeCAD FA&Q");
sToolTipText = QT_TR_NOOP("Opens the Frequently Asked Questions");
sWhatsThis = "Std_FreeCADFAQ";
sStatusTip = sToolTipText;
@@ -766,7 +766,7 @@ StdCmdReportBug::StdCmdReportBug()
:Command("Std_ReportBug")
{
sGroup = "Help";
sMenuText = QT_TR_NOOP("Report an Issue");
sMenuText = QT_TR_NOOP("Report an &Issue");
sToolTipText = QT_TR_NOOP("Report an issue or suggest a new feature");
sWhatsThis = "Std_ReportBug";
sStatusTip = sToolTipText;
@@ -793,7 +793,7 @@ StdCmdTextDocument::StdCmdTextDocument()
:Command("Std_TextDocument")
{
sGroup = "Tools";
sMenuText = QT_TR_NOOP("Add text document");
sMenuText = QT_TR_NOOP("Add te&xt document");
sToolTipText = QT_TR_NOOP("Add text document to active document");
sWhatsThis = "Std_TextDocument";
sStatusTip = QT_TR_NOOP("Add text document to active document");
@@ -862,7 +862,7 @@ StdCmdUserEditMode::StdCmdUserEditMode()
: Command("Std_UserEditMode")
{
sGroup = "Edit";
sMenuText = QT_TR_NOOP("Edit mode");
sMenuText = QT_TR_NOOP("Edit &mode");
sToolTipText = QT_TR_NOOP("Defines behavior when editing an object from tree");
sStatusTip = QT_TR_NOOP("Defines behavior when editing an object from tree");
sWhatsThis = "Std_UserEditMode";
@@ -883,7 +883,7 @@ Gui::Action * StdCmdUserEditMode::createAction()
for (auto const &uem : Gui::Application::Instance->listUserEditModes()) {
QAction* act = pcAction->addAction(QString());
auto modeName = QString::fromStdString(uem.second.first);
auto modeName = QString::fromStdString(uem.second.first).remove(QChar::fromLatin1('&'));
act->setCheckable(true);
act->setIcon(BitmapFactory().iconFromTheme(qPrintable(QString::fromLatin1("Std_UserEditMode")+modeName)));
act->setObjectName(QString::fromLatin1("Std_UserEditMode")+modeName);
+2 -2
View File
@@ -156,9 +156,9 @@ void StdCmdVarSet::activated(int iMsg)
// add the varset to a group if it is selected
auto sels = Selection().getSelectionEx(nullptr, App::DocumentObject::getClassTypeId(),
ResolveMode::OldStyleElement, true);
ResolveMode::OldStyleElement, true);
if (sels.size() == 1) {
App::DocumentObject *obj = sels[0].getObject();
App::DocumentObject* obj = sels[0].getObject();
auto group = obj->getExtension<App::GroupExtension>();
if (group) {
Gui::Document* docGui = Application::Instance->activeDocument();
+88 -88
View File
@@ -320,7 +320,7 @@ StdCmdFreezeViews::StdCmdFreezeViews()
: Command("Std_FreezeViews")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Freeze display");
sMenuText = QT_TR_NOOP("F&reeze display");
sToolTipText = QT_TR_NOOP("Freezes the current view position");
sWhatsThis = "Std_FreezeViews";
sStatusTip = QT_TR_NOOP("Freezes the current view position");
@@ -335,15 +335,15 @@ Action * StdCmdFreezeViews::createAction()
applyCommandData(this->className(), pcAction);
// add the action items
saveView = pcAction->addAction(QObject::tr("Save views..."));
saveView = pcAction->addAction(QObject::tr("&Save views..."));
saveView->setWhatsThis(QString::fromLatin1(getWhatsThis()));
QAction* loadView = pcAction->addAction(QObject::tr("Load views..."));
QAction* loadView = pcAction->addAction(QObject::tr("&Load views..."));
loadView->setWhatsThis(QString::fromLatin1(getWhatsThis()));
pcAction->addAction(QString::fromLatin1(""))->setSeparator(true);
freezeView = pcAction->addAction(QObject::tr("Freeze view"));
freezeView = pcAction->addAction(QObject::tr("F&reeze view"));
freezeView->setShortcut(QString::fromLatin1(getAccel()));
freezeView->setWhatsThis(QString::fromLatin1(getWhatsThis()));
clearView = pcAction->addAction(QObject::tr("Clear views"));
clearView = pcAction->addAction(QObject::tr("&Clear views"));
clearView->setWhatsThis(QString::fromLatin1(getWhatsThis()));
separator = pcAction->addAction(QString::fromLatin1(""));
separator->setSeparator(true);
@@ -568,10 +568,10 @@ void StdCmdFreezeViews::languageChange()
return;
auto pcAction = qobject_cast<ActionGroup*>(_pcAction);
QList<QAction*> acts = pcAction->actions();
acts[0]->setText(QObject::tr("Save views..."));
acts[1]->setText(QObject::tr("Load views..."));
acts[3]->setText(QObject::tr("Freeze view"));
acts[4]->setText(QObject::tr("Clear views"));
acts[0]->setText(QObject::tr("&Save views..."));
acts[1]->setText(QObject::tr("&Load views..."));
acts[3]->setText(QObject::tr("F&reeze view"));
acts[4]->setText(QObject::tr("&Clear views"));
int index=1;
for (QList<QAction*>::Iterator it = acts.begin()+5; it != acts.end(); ++it, index++) {
if ((*it)->isVisible()) {
@@ -592,7 +592,7 @@ StdCmdToggleClipPlane::StdCmdToggleClipPlane()
: Command("Std_ToggleClipPlane")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Clipping plane");
sMenuText = QT_TR_NOOP("Clippin&g plane");
sToolTipText = QT_TR_NOOP("Toggles clipping plane for active view");
sWhatsThis = "Std_ToggleClipPlane";
sStatusTip = QT_TR_NOOP("Toggles clipping plane for active view");
@@ -645,7 +645,7 @@ StdCmdDrawStyle::StdCmdDrawStyle()
: Command("Std_DrawStyle")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Draw style");
sMenuText = QT_TR_NOOP("&Draw style");
sToolTipText = QT_TR_NOOP("Change the draw style of the objects");
sStatusTip = QT_TR_NOOP("Change the draw style of the objects");
sWhatsThis = "Std_DrawStyle";
@@ -725,37 +725,37 @@ void StdCmdDrawStyle::languageChange()
QList<QAction*> a = pcAction->actions();
a[0]->setText(QCoreApplication::translate(
"Std_DrawStyle", "As is"));
"Std_DrawStyle", "&1 As is"));
a[0]->setToolTip(QCoreApplication::translate(
"Std_DrawStyle", "Normal mode"));
a[1]->setText(QCoreApplication::translate(
"Std_DrawStyle", "Points"));
"Std_DrawStyle", "&2 Points"));
a[1]->setToolTip(QCoreApplication::translate(
"Std_DrawStyle", "Points mode"));
a[2]->setText(QCoreApplication::translate(
"Std_DrawStyle", "Wireframe"));
"Std_DrawStyle", "&3 Wireframe"));
a[2]->setToolTip(QCoreApplication::translate(
"Std_DrawStyle", "Wireframe mode"));
a[3]->setText(QCoreApplication::translate(
"Std_DrawStyle", "Hidden line"));
"Std_DrawStyle", "&4 Hidden line"));
a[3]->setToolTip(QCoreApplication::translate(
"Std_DrawStyle", "Hidden line mode"));
a[4]->setText(QCoreApplication::translate(
"Std_DrawStyle", "No shading"));
"Std_DrawStyle", "&5 No shading"));
a[4]->setToolTip(QCoreApplication::translate(
"Std_DrawStyle", "No shading mode"));
a[5]->setText(QCoreApplication::translate(
"Std_DrawStyle", "Shaded"));
"Std_DrawStyle", "&6 Shaded"));
a[5]->setToolTip(QCoreApplication::translate(
"Std_DrawStyle", "Shaded mode"));
a[6]->setText(QCoreApplication::translate(
"Std_DrawStyle", "Flat lines"));
"Std_DrawStyle", "&7 Flat lines"));
a[6]->setToolTip(QCoreApplication::translate(
"Std_DrawStyle", "Flat lines mode"));
}
@@ -865,7 +865,7 @@ StdCmdToggleVisibility::StdCmdToggleVisibility()
: Command("Std_ToggleVisibility")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Toggle visibility");
sMenuText = QT_TR_NOOP("Toggle &visibility");
sToolTipText = QT_TR_NOOP("Toggles visibility");
sStatusTip = QT_TR_NOOP("Toggles visibility");
sWhatsThis = "Std_ToggleVisibility";
@@ -896,7 +896,7 @@ StdCmdToggleTransparency::StdCmdToggleTransparency()
: Command("Std_ToggleTransparency")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Toggle transparency");
sMenuText = QT_TR_NOOP("Toggle transparenc&y");
static std::string toolTip = std::string("<p>")
+ QT_TR_NOOP("Toggles transparency of the selected objects. You can also fine tune transparency "
"value in the Appearance taskbox (right click an object in the tree, Appearance).")
@@ -1003,7 +1003,7 @@ StdCmdToggleSelectability::StdCmdToggleSelectability()
: Command("Std_ToggleSelectability")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Toggle selectability");
sMenuText = QT_TR_NOOP("Toggle se&lectability");
sToolTipText = QT_TR_NOOP("Toggles the property of the objects to get selected in the 3D-View");
sStatusTip = QT_TR_NOOP("Toggles the property of the objects to get selected in the 3D-View");
sWhatsThis = "Std_ToggleSelectability";
@@ -1055,7 +1055,7 @@ StdCmdShowSelection::StdCmdShowSelection()
: Command("Std_ShowSelection")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Show selection");
sMenuText = QT_TR_NOOP("Sho&w selection");
sToolTipText = QT_TR_NOOP("Show all selected objects");
sStatusTip = QT_TR_NOOP("Show all selected objects");
sWhatsThis = "Std_ShowSelection";
@@ -1083,7 +1083,7 @@ StdCmdHideSelection::StdCmdHideSelection()
: Command("Std_HideSelection")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Hide selection");
sMenuText = QT_TR_NOOP("&Hide selection");
sToolTipText = QT_TR_NOOP("Hide all selected objects");
sStatusTip = QT_TR_NOOP("Hide all selected objects");
sWhatsThis = "Std_HideSelection";
@@ -1111,7 +1111,7 @@ StdCmdSelectVisibleObjects::StdCmdSelectVisibleObjects()
: Command("Std_SelectVisibleObjects")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Select visible objects");
sMenuText = QT_TR_NOOP("&Select visible objects");
sToolTipText = QT_TR_NOOP("Select visible objects in the active document");
sStatusTip = QT_TR_NOOP("Select visible objects in the active document");
sWhatsThis = "Std_SelectVisibleObjects";
@@ -1153,7 +1153,7 @@ StdCmdToggleObjects::StdCmdToggleObjects()
: Command("Std_ToggleObjects")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Toggle all objects");
sMenuText = QT_TR_NOOP("To&ggle all objects");
sToolTipText = QT_TR_NOOP("Toggles visibility of all objects in the active document");
sStatusTip = QT_TR_NOOP("Toggles visibility of all objects in the active document");
sWhatsThis = "Std_ToggleObjects";
@@ -1194,7 +1194,7 @@ StdCmdShowObjects::StdCmdShowObjects()
: Command("Std_ShowObjects")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Show all objects");
sMenuText = QT_TR_NOOP("Show &all objects");
sToolTipText = QT_TR_NOOP("Show all objects in the document");
sStatusTip = QT_TR_NOOP("Show all objects in the document");
sWhatsThis = "Std_ShowObjects";
@@ -1231,7 +1231,7 @@ StdCmdHideObjects::StdCmdHideObjects()
: Command("Std_HideObjects")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Hide all objects");
sMenuText = QT_TR_NOOP("Hide all &objects");
sToolTipText = QT_TR_NOOP("Hide all objects in the document");
sStatusTip = QT_TR_NOOP("Hide all objects in the document");
sWhatsThis = "Std_HideObjects";
@@ -1268,7 +1268,7 @@ StdCmdViewHome::StdCmdViewHome()
: Command("Std_ViewHome")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Home");
sMenuText = QT_TR_NOOP("&Home");
sToolTipText = QT_TR_NOOP("Set to default home view");
sWhatsThis = "Std_ViewHome";
sStatusTip = QT_TR_NOOP("Set to default home view");
@@ -1296,7 +1296,7 @@ StdCmdViewBottom::StdCmdViewBottom()
: Command("Std_ViewBottom")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Bottom");
sMenuText = QT_TR_NOOP("&5 Bottom");
sToolTipText = QT_TR_NOOP("Set to bottom view");
sWhatsThis = "Std_ViewBottom";
sStatusTip = QT_TR_NOOP("Set to bottom view");
@@ -1320,7 +1320,7 @@ StdCmdViewFront::StdCmdViewFront()
: Command("Std_ViewFront")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Front");
sMenuText = QT_TR_NOOP("&1 Front");
sToolTipText = QT_TR_NOOP("Set to front view");
sWhatsThis = "Std_ViewFront";
sStatusTip = QT_TR_NOOP("Set to front view");
@@ -1344,7 +1344,7 @@ StdCmdViewLeft::StdCmdViewLeft()
: Command("Std_ViewLeft")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Left");
sMenuText = QT_TR_NOOP("&6 Left");
sToolTipText = QT_TR_NOOP("Set to left view");
sWhatsThis = "Std_ViewLeft";
sStatusTip = QT_TR_NOOP("Set to left view");
@@ -1368,7 +1368,7 @@ StdCmdViewRear::StdCmdViewRear()
: Command("Std_ViewRear")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Rear");
sMenuText = QT_TR_NOOP("&4 Rear");
sToolTipText = QT_TR_NOOP("Set to rear view");
sWhatsThis = "Std_ViewRear";
sStatusTip = QT_TR_NOOP("Set to rear view");
@@ -1392,7 +1392,7 @@ StdCmdViewRight::StdCmdViewRight()
: Command("Std_ViewRight")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Right");
sMenuText = QT_TR_NOOP("&3 Right");
sToolTipText = QT_TR_NOOP("Set to right view");
sWhatsThis = "Std_ViewRight";
sStatusTip = QT_TR_NOOP("Set to right view");
@@ -1416,7 +1416,7 @@ StdCmdViewTop::StdCmdViewTop()
: Command("Std_ViewTop")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Top");
sMenuText = QT_TR_NOOP("&2 Top");
sToolTipText = QT_TR_NOOP("Set to top view");
sWhatsThis = "Std_ViewTop";
sStatusTip = QT_TR_NOOP("Set to top view");
@@ -1441,7 +1441,7 @@ StdCmdViewIsometric::StdCmdViewIsometric()
: Command("Std_ViewIsometric")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Isometric");
sMenuText = QT_TR_NOOP("&Isometric");
sToolTipText= QT_TR_NOOP("Set to isometric view");
sWhatsThis = "Std_ViewIsometric";
sStatusTip = QT_TR_NOOP("Set to isometric view");
@@ -1465,7 +1465,7 @@ StdCmdViewDimetric::StdCmdViewDimetric()
: Command("Std_ViewDimetric")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Dimetric");
sMenuText = QT_TR_NOOP("&Dimetric");
sToolTipText= QT_TR_NOOP("Set to dimetric view");
sWhatsThis = "Std_ViewDimetric";
sStatusTip = QT_TR_NOOP("Set to dimetric view");
@@ -1488,7 +1488,7 @@ StdCmdViewTrimetric::StdCmdViewTrimetric()
: Command("Std_ViewTrimetric")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Trimetric");
sMenuText = QT_TR_NOOP("&Trimetric");
sToolTipText= QT_TR_NOOP("Set to trimetric view");
sWhatsThis = "Std_ViewTrimetric";
sStatusTip = QT_TR_NOOP("Set to trimetric view");
@@ -1511,7 +1511,7 @@ StdCmdViewRotateLeft::StdCmdViewRotateLeft()
: Command("Std_ViewRotateLeft")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Rotate Left");
sMenuText = QT_TR_NOOP("Rotate &Left");
sToolTipText = QT_TR_NOOP("Rotate the view by 90\xc2\xb0 counter-clockwise");
sWhatsThis = "Std_ViewRotateLeft";
sStatusTip = QT_TR_NOOP("Rotate the view by 90\xc2\xb0 counter-clockwise");
@@ -1536,7 +1536,7 @@ StdCmdViewRotateRight::StdCmdViewRotateRight()
: Command("Std_ViewRotateRight")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Rotate Right");
sMenuText = QT_TR_NOOP("Rotate &Right");
sToolTipText = QT_TR_NOOP("Rotate the view by 90\xc2\xb0 clockwise");
sWhatsThis = "Std_ViewRotateRight";
sStatusTip = QT_TR_NOOP("Rotate the view by 90\xc2\xb0 clockwise");
@@ -1561,7 +1561,7 @@ StdCmdViewFitAll::StdCmdViewFitAll()
: Command("Std_ViewFitAll")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Fit all");
sMenuText = QT_TR_NOOP("&Fit all");
sToolTipText = QT_TR_NOOP("Fits the whole content on the screen");
sWhatsThis = "Std_ViewFitAll";
sStatusTip = QT_TR_NOOP("Fits the whole content on the screen");
@@ -1592,7 +1592,7 @@ StdCmdViewFitSelection::StdCmdViewFitSelection()
: Command("Std_ViewFitSelection")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Fit selection");
sMenuText = QT_TR_NOOP("Fit &selection");
sToolTipText = QT_TR_NOOP("Fits the selected content on the screen");
sWhatsThis = "Std_ViewFitSelection";
sStatusTip = QT_TR_NOOP("Fits the selected content on the screen");
@@ -1622,7 +1622,7 @@ public:
: GroupCommand("Std_ViewGroup")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Standard views");
sMenuText = QT_TR_NOOP("Standard &views");
sToolTipText = QT_TR_NOOP("Change to a standard view");
sStatusTip = QT_TR_NOOP("Change to a standard view");
sWhatsThis = "Std_ViewGroup";
@@ -1661,7 +1661,7 @@ StdViewDock::StdViewDock()
: Command("Std_ViewDock")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Docked");
sMenuText = QT_TR_NOOP("&Docked");
sToolTipText = QT_TR_NOOP("Display the active view either in fullscreen, in undocked or docked mode");
sWhatsThis = "Std_ViewDock";
sStatusTip = QT_TR_NOOP("Display the active view either in fullscreen, in undocked or docked mode");
@@ -1690,7 +1690,7 @@ StdViewUndock::StdViewUndock()
: Command("Std_ViewUndock")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Undocked");
sMenuText = QT_TR_NOOP("&Undocked");
sToolTipText = QT_TR_NOOP("Display the active view either in fullscreen, in undocked or docked mode");
sWhatsThis = "Std_ViewUndock";
sStatusTip = QT_TR_NOOP("Display the active view either in fullscreen, in undocked or docked mode");
@@ -1751,7 +1751,7 @@ StdViewFullscreen::StdViewFullscreen()
: Command("Std_ViewFullscreen")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Fullscreen");
sMenuText = QT_TR_NOOP("&Fullscreen");
sToolTipText = QT_TR_NOOP("Display the active view either in fullscreen, in undocked or docked mode");
sWhatsThis = "Std_ViewFullscreen";
sStatusTip = QT_TR_NOOP("Display the active view either in fullscreen, in undocked or docked mode");
@@ -1781,7 +1781,7 @@ StdViewDockUndockFullscreen::StdViewDockUndockFullscreen()
: Command("Std_ViewDockUndockFullscreen")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Document window");
sMenuText = QT_TR_NOOP("D&ocument window");
sToolTipText = QT_TR_NOOP("Display the active view either in fullscreen, in undocked or docked mode");
sWhatsThis = "Std_ViewDockUndockFullscreen";
sStatusTip = QT_TR_NOOP("Display the active view either in fullscreen, in undocked or docked mode");
@@ -1923,7 +1923,7 @@ StdViewScreenShot::StdViewScreenShot()
: Command("Std_ViewScreenShot")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Save image...");
sMenuText = QT_TR_NOOP("Save &image...");
sToolTipText= QT_TR_NOOP("Creates a screenshot of the active view");
sWhatsThis = "Std_ViewScreenShot";
sStatusTip = QT_TR_NOOP("Creates a screenshot of the active view");
@@ -2094,7 +2094,7 @@ StdViewLoadImage::StdViewLoadImage()
: Command("Std_ViewLoadImage")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Load image...");
sMenuText = QT_TR_NOOP("&Load image...");
sToolTipText= QT_TR_NOOP("Loads an image");
sWhatsThis = "Std_ViewLoadImage";
sStatusTip = QT_TR_NOOP("Loads an image");
@@ -2169,7 +2169,7 @@ StdCmdToggleNavigation::StdCmdToggleNavigation()
: Command("Std_ToggleNavigation")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Toggle navigation/Edit mode");
sMenuText = QT_TR_NOOP("Toggle navigation/&Edit mode");
sToolTipText = QT_TR_NOOP("Toggle between navigation and edit mode");
sStatusTip = QT_TR_NOOP("Toggle between navigation and edit mode");
sWhatsThis = "Std_ToggleNavigation";
@@ -2218,7 +2218,7 @@ StdCmdAxisCross::StdCmdAxisCross()
: Command("Std_AxisCross")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Toggle axis cross");
sMenuText = QT_TR_NOOP("Toggle a&xis cross");
sToolTipText = QT_TR_NOOP("Turns on or off the axis cross at the origin");
sStatusTip = QT_TR_NOOP("Turns on or off the axis cross at the origin");
sWhatsThis = "Std_AxisCross";
@@ -2349,7 +2349,7 @@ StdCmdViewIvStereoOff::StdCmdViewIvStereoOff()
: Command("Std_ViewIvStereoOff")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Stereo Off");
sMenuText = QT_TR_NOOP("Stereo &Off");
sToolTipText = QT_TR_NOOP("Switch stereo viewing off");
sWhatsThis = "Std_ViewIvStereoOff";
sStatusTip = QT_TR_NOOP("Switch stereo viewing off");
@@ -2378,7 +2378,7 @@ StdCmdViewIvStereoRedGreen::StdCmdViewIvStereoRedGreen()
: Command("Std_ViewIvStereoRedGreen")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Stereo red/cyan");
sMenuText = QT_TR_NOOP("Stereo re&d/cyan");
sToolTipText = QT_TR_NOOP("Switch stereo viewing to red/cyan");
sWhatsThis = "Std_ViewIvStereoRedGreen";
sStatusTip = QT_TR_NOOP("Switch stereo viewing to red/cyan");
@@ -2406,7 +2406,7 @@ StdCmdViewIvStereoQuadBuff::StdCmdViewIvStereoQuadBuff()
: Command("Std_ViewIvStereoQuadBuff")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Stereo quad buffer");
sMenuText = QT_TR_NOOP("Stereo &quad buffer");
sToolTipText = QT_TR_NOOP("Switch stereo viewing to quad buffer");
sWhatsThis = "Std_ViewIvStereoQuadBuff";
sStatusTip = QT_TR_NOOP("Switch stereo viewing to quad buffer");
@@ -2434,7 +2434,7 @@ StdCmdViewIvStereoInterleavedRows::StdCmdViewIvStereoInterleavedRows()
: Command("Std_ViewIvStereoInterleavedRows")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Stereo Interleaved Rows");
sMenuText = QT_TR_NOOP("Stereo Interleaved &Rows");
sToolTipText = QT_TR_NOOP("Switch stereo viewing to Interleaved Rows");
sWhatsThis = "Std_ViewIvStereoInterleavedRows";
sStatusTip = QT_TR_NOOP("Switch stereo viewing to Interleaved Rows");
@@ -2462,7 +2462,7 @@ StdCmdViewIvStereoInterleavedColumns::StdCmdViewIvStereoInterleavedColumns()
: Command("Std_ViewIvStereoInterleavedColumns")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Stereo Interleaved Columns");
sMenuText = QT_TR_NOOP("Stereo Interleaved &Columns");
sToolTipText = QT_TR_NOOP("Switch stereo viewing to Interleaved Columns");
sWhatsThis = "Std_ViewIvStereoInterleavedColumns";
sStatusTip = QT_TR_NOOP("Switch stereo viewing to Interleaved Columns");
@@ -2491,7 +2491,7 @@ StdCmdViewIvIssueCamPos::StdCmdViewIvIssueCamPos()
: Command("Std_ViewIvIssueCamPos")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Issue camera position");
sMenuText = QT_TR_NOOP("Issue camera &position");
sToolTipText = QT_TR_NOOP("Issue the camera position to the console and to a macro, to easily recall this position");
sWhatsThis = "Std_ViewIvIssueCamPos";
sStatusTip = QT_TR_NOOP("Issue the camera position to the console and to a macro, to easily recall this position");
@@ -2541,7 +2541,7 @@ StdViewZoomIn::StdViewZoomIn()
: Command("Std_ViewZoomIn")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Zoom In");
sMenuText = QT_TR_NOOP("Zoom &In");
sToolTipText = QT_TR_NOOP("Increase the zoom factor by a fixed amount");
sWhatsThis = "Std_ViewZoomIn";
sStatusTip = QT_TR_NOOP("Increase the zoom factor by a fixed amount");
@@ -2570,7 +2570,7 @@ StdViewZoomOut::StdViewZoomOut()
: Command("Std_ViewZoomOut")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Zoom Out");
sMenuText = QT_TR_NOOP("Zoom &Out");
sToolTipText = QT_TR_NOOP("Decrease the zoom factor by a fixed amount");
sWhatsThis = "Std_ViewZoomOut";
sStatusTip = QT_TR_NOOP("Decrease the zoom factor by a fixed amount");
@@ -2716,7 +2716,7 @@ StdViewBoxZoom::StdViewBoxZoom()
: Command("Std_ViewBoxZoom")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Box zoom");
sMenuText = QT_TR_NOOP("&Box zoom");
sToolTipText = QT_TR_NOOP("Activate the box zoom tool");
sWhatsThis = "Std_ViewBoxZoom";
sStatusTip = QT_TR_NOOP("Activate the box zoom tool");
@@ -2750,7 +2750,7 @@ StdBoxSelection::StdBoxSelection()
: Command("Std_BoxSelection")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Box selection");
sMenuText = QT_TR_NOOP("&Box selection");
sToolTipText = QT_TR_NOOP("Activate the box selection tool");
sWhatsThis = "Std_BoxSelection";
sStatusTip = QT_TR_NOOP("Activate the box selection tool");
@@ -2976,7 +2976,7 @@ StdBoxElementSelection::StdBoxElementSelection()
: Command("Std_BoxElementSelection")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Box element selection");
sMenuText = QT_TR_NOOP("Bo&x element selection");
sToolTipText = QT_TR_NOOP("Box element selection");
sWhatsThis = "Std_BoxElementSelection";
sStatusTip = QT_TR_NOOP("Box element selection");
@@ -3021,7 +3021,7 @@ StdTreeSelection::StdTreeSelection()
: Command("Std_TreeSelection")
{
sGroup = "TreeView";
sMenuText = QT_TR_NOOP("Go to selection");
sMenuText = QT_TR_NOOP("&Go to selection");
sToolTipText = QT_TR_NOOP("Scroll to first selected item");
sWhatsThis = "Std_TreeSelection";
sStatusTip = QT_TR_NOOP("Scroll to first selected item");
@@ -3149,7 +3149,7 @@ StdCmdSceneInspector::StdCmdSceneInspector()
{
// setting the
sGroup = "Tools";
sMenuText = QT_TR_NOOP("Scene inspector...");
sMenuText = QT_TR_NOOP("Scene i&nspector...");
sToolTipText = QT_TR_NOOP("Scene inspector");
sWhatsThis = "Std_SceneInspector";
sStatusTip = QT_TR_NOOP("Scene inspector");
@@ -3182,7 +3182,7 @@ StdCmdTextureMapping::StdCmdTextureMapping()
{
// setting the
sGroup = "Tools";
sMenuText = QT_TR_NOOP("Texture mapping...");
sMenuText = QT_TR_NOOP("Text&ure mapping...");
sToolTipText = QT_TR_NOOP("Texture mapping");
sWhatsThis = "Std_TextureMapping";
sStatusTip = QT_TR_NOOP("Texture mapping");
@@ -3209,7 +3209,7 @@ StdCmdDemoMode::StdCmdDemoMode()
: Command("Std_DemoMode")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("View turntable...");
sMenuText = QT_TR_NOOP("View &turntable...");
sToolTipText = QT_TR_NOOP("View turntable");
sWhatsThis = "Std_DemoMode";
sStatusTip = QT_TR_NOOP("View turntable");
@@ -3238,7 +3238,7 @@ StdCmdSelBack::StdCmdSelBack()
:Command("Std_SelBack")
{
sGroup = "View";
sMenuText = QT_TR_NOOP("Selection back");
sMenuText = QT_TR_NOOP("Selection &back");
static std::string toolTip = std::string("<p>")
+ QT_TR_NOOP("Restore the previous Tree view selection. "
"Only works if Tree RecordSelection mode is switched on.")
@@ -3272,7 +3272,7 @@ StdCmdSelForward::StdCmdSelForward()
:Command("Std_SelForward")
{
sGroup = "View";
sMenuText = QT_TR_NOOP("Selection forward");
sMenuText = QT_TR_NOOP("Selection &forward");
static std::string toolTip = std::string("<p>")
+ QT_TR_NOOP("Restore the next Tree view selection. "
"Only works if Tree RecordSelection mode is switched on.")
@@ -3326,7 +3326,7 @@ StdTreeSingleDocument::StdTreeSingleDocument()
: Command("Std_TreeSingleDocument")
{
sGroup = "TreeView";
sMenuText = QT_TR_NOOP("Single document");
sMenuText = QT_TR_NOOP("&Single document");
sToolTipText = QT_TR_NOOP("Only display the active document in the tree view");
sWhatsThis = "Std_TreeSingleDocument";
sStatusTip = QT_TR_NOOP("Only display the active document in the tree view");
@@ -3343,7 +3343,7 @@ StdTreeMultiDocument::StdTreeMultiDocument()
: Command("Std_TreeMultiDocument")
{
sGroup = "TreeView";
sMenuText = QT_TR_NOOP("Multi document");
sMenuText = QT_TR_NOOP("&Multi document");
sToolTipText = QT_TR_NOOP("Display all documents in the tree view");
sWhatsThis = "Std_TreeMultiDocument";
sStatusTip = QT_TR_NOOP("Display all documents in the tree view");
@@ -3360,7 +3360,7 @@ StdTreeCollapseDocument::StdTreeCollapseDocument()
: Command("Std_TreeCollapseDocument")
{
sGroup = "TreeView";
sMenuText = QT_TR_NOOP("Collapse/Expand");
sMenuText = QT_TR_NOOP("Collapse/E&xpand");
sToolTipText = QT_TR_NOOP("Expand active document and collapse all others");
sWhatsThis = "Std_TreeCollapseDocument";
sStatusTip = QT_TR_NOOP("Expand active document and collapse all others");
@@ -3399,7 +3399,7 @@ StdTreeSyncView::StdTreeSyncView()
: Command("Std_TreeSyncView")
{
sGroup = "TreeView";
sMenuText = QT_TR_NOOP("Sync view");
sMenuText = QT_TR_NOOP("&1 Sync view");
sToolTipText = QT_TR_NOOP("Auto switch to the 3D view containing the selected item");
sStatusTip = sToolTipText;
sWhatsThis = "Std_TreeSyncView";
@@ -3417,7 +3417,7 @@ StdTreeSyncSelection::StdTreeSyncSelection()
: Command("Std_TreeSyncSelection")
{
sGroup = "TreeView";
sMenuText = QT_TR_NOOP("Sync selection");
sMenuText = QT_TR_NOOP("&2 Sync selection");
sToolTipText = QT_TR_NOOP("Auto expand tree item when the corresponding object is selected in 3D view");
sStatusTip = sToolTipText;
sWhatsThis = "Std_TreeSyncSelection";
@@ -3435,7 +3435,7 @@ StdTreeSyncPlacement::StdTreeSyncPlacement()
: Command("Std_TreeSyncPlacement")
{
sGroup = "TreeView";
sMenuText = QT_TR_NOOP("Sync placement");
sMenuText = QT_TR_NOOP("&3 Sync placement");
sToolTipText = QT_TR_NOOP("Auto adjust placement on drag and drop objects across coordinate systems");
sStatusTip = sToolTipText;
sWhatsThis = "Std_TreeSyncPlacement";
@@ -3453,7 +3453,7 @@ StdTreePreSelection::StdTreePreSelection()
: Command("Std_TreePreSelection")
{
sGroup = "TreeView";
sMenuText = QT_TR_NOOP("Pre-selection");
sMenuText = QT_TR_NOOP("&4 Pre-selection");
sToolTipText = QT_TR_NOOP("Preselect the object in 3D view when hovering the cursor over the tree item");
sStatusTip = sToolTipText;
sWhatsThis = "Std_TreePreSelection";
@@ -3471,7 +3471,7 @@ StdTreeRecordSelection::StdTreeRecordSelection()
: Command("Std_TreeRecordSelection")
{
sGroup = "TreeView";
sMenuText = QT_TR_NOOP("Record selection");
sMenuText = QT_TR_NOOP("&5 Record selection");
sToolTipText = QT_TR_NOOP("Record selection in tree view in order to go back/forward using navigation button");
sStatusTip = sToolTipText;
sWhatsThis = "Std_TreeRecordSelection";
@@ -3489,7 +3489,7 @@ StdTreeDrag::StdTreeDrag()
: Command("Std_TreeDrag")
{
sGroup = "TreeView";
sMenuText = QT_TR_NOOP("Initiate dragging");
sMenuText = QT_TR_NOOP("Initiate &dragging");
sToolTipText = QT_TR_NOOP("Initiate dragging of current selected tree items");
sStatusTip = sToolTipText;
sWhatsThis = "Std_TreeDrag";
@@ -3609,7 +3609,7 @@ StdCmdDockOverlayAll::StdCmdDockOverlayAll()
:Command("Std_DockOverlayAll")
{
sGroup = "View";
sMenuText = QT_TR_NOOP("Toggle overlay for all");
sMenuText = QT_TR_NOOP("Toggle overl&ay for all");
sToolTipText = QT_TR_NOOP("Toggle overlay mode for all docked windows");
sWhatsThis = "Std_DockOverlayAll";
sStatusTip = sToolTipText;
@@ -3633,7 +3633,7 @@ StdCmdDockOverlayTransparentAll::StdCmdDockOverlayTransparentAll()
:Command("Std_DockOverlayTransparentAll")
{
sGroup = "View";
sMenuText = QT_TR_NOOP("Toggle transparent for all");
sMenuText = QT_TR_NOOP("Toggle tra&nsparent for all");
sToolTipText = QT_TR_NOOP("Toggle transparent mode for all docked overlay windows.\n"
"This makes the docked windows stay transparent at all times.");
sWhatsThis = "Std_DockOverlayTransparentAll";
@@ -3658,7 +3658,7 @@ StdCmdDockOverlayToggle::StdCmdDockOverlayToggle()
:Command("Std_DockOverlayToggle")
{
sGroup = "View";
sMenuText = QT_TR_NOOP("Toggle overlay");
sMenuText = QT_TR_NOOP("Toggle &overlay");
sToolTipText = QT_TR_NOOP("Toggle overlay mode for the docked window under the cursor");
sWhatsThis = "Std_DockOverlayToggle";
sStatusTip = sToolTipText;
@@ -3682,7 +3682,7 @@ StdCmdDockOverlayToggleTransparent::StdCmdDockOverlayToggleTransparent()
:Command("Std_DockOverlayToggleTransparent")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Toggle transparent mode");
sMenuText = QT_TR_NOOP("Toggle tran&sparent mode");
sToolTipText = QT_TR_NOOP("Toggle transparent mode for the docked window under cursor.\n"
"This makes the docked window stay transparent at all times.");
sWhatsThis = "Std_DockOverlayToggleTransparent";
@@ -3707,7 +3707,7 @@ StdCmdDockOverlayToggleLeft::StdCmdDockOverlayToggleLeft()
:Command("Std_DockOverlayToggleLeft")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Toggle left");
sMenuText = QT_TR_NOOP("Toggle &left");
sToolTipText = QT_TR_NOOP("Show/hide left overlay panel");
sWhatsThis = "Std_DockOverlayToggleLeft";
sStatusTip = sToolTipText;
@@ -3732,7 +3732,7 @@ StdCmdDockOverlayToggleRight::StdCmdDockOverlayToggleRight()
:Command("Std_DockOverlayToggleRight")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Toggle right");
sMenuText = QT_TR_NOOP("Toggle &right");
sToolTipText = QT_TR_NOOP("Show/hide right overlay panel");
sWhatsThis = "Std_DockOverlayToggleRight";
sStatusTip = sToolTipText;
@@ -3757,7 +3757,7 @@ StdCmdDockOverlayToggleTop::StdCmdDockOverlayToggleTop()
:Command("Std_DockOverlayToggleTop")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Toggle top");
sMenuText = QT_TR_NOOP("Toggle &top");
sToolTipText = QT_TR_NOOP("Show/hide top overlay panel");
sWhatsThis = "Std_DockOverlayToggleTop";
sStatusTip = sToolTipText;
@@ -3782,7 +3782,7 @@ StdCmdDockOverlayToggleBottom::StdCmdDockOverlayToggleBottom()
:Command("Std_DockOverlayToggleBottom")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Toggle bottom");
sMenuText = QT_TR_NOOP("Toggle &bottom");
sToolTipText = QT_TR_NOOP("Show/hide bottom overlay panel");
sWhatsThis = "Std_DockOverlayToggleBottom";
sStatusTip = sToolTipText;
@@ -3807,7 +3807,7 @@ StdCmdDockOverlayMouseTransparent::StdCmdDockOverlayMouseTransparent()
:Command("Std_DockOverlayMouseTransparent")
{
sGroup = "View";
sMenuText = QT_TR_NOOP("Bypass mouse events in docked overlay windows");
sMenuText = QT_TR_NOOP("Bypass &mouse events in docked overlay windows");
sToolTipText = QT_TR_NOOP("Bypass all mouse events in docked overlay windows");
sWhatsThis = "Std_DockOverlayMouseTransparent";
sStatusTip = sToolTipText;
@@ -3881,7 +3881,7 @@ StdStoreWorkingView::StdStoreWorkingView()
: Command("Std_StoreWorkingView")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Store working view");
sMenuText = QT_TR_NOOP("St&ore working view");
sToolTipText = QT_TR_NOOP("Store a document-specific temporary working view");
sStatusTip = QT_TR_NOOP("Store a document-specific temporary working view");
sWhatsThis = "Std_StoreWorkingView";
@@ -3911,7 +3911,7 @@ StdRecallWorkingView::StdRecallWorkingView()
: Command("Std_RecallWorkingView")
{
sGroup = "Standard-View";
sMenuText = QT_TR_NOOP("Recall working view");
sMenuText = QT_TR_NOOP("R&ecall working view");
sToolTipText = QT_TR_NOOP("Recall previously stored temporary working view");
sStatusTip = QT_TR_NOOP("Recall previously stored temporary working view");
sWhatsThis = "Std_RecallWorkingView";
@@ -3943,7 +3943,7 @@ StdCmdAlignToSelection::StdCmdAlignToSelection()
: Command("Std_AlignToSelection")
{
sGroup = "View";
sMenuText = QT_TR_NOOP("Align to selection");
sMenuText = QT_TR_NOOP("&Align to selection");
sToolTipText = QT_TR_NOOP("Align the view with the selection");
sWhatsThis = "Std_AlignToSelection";
sPixmap = "align-to-selection";
+6 -6
View File
@@ -109,7 +109,7 @@ StdCmdCloseActiveWindow::StdCmdCloseActiveWindow()
: Command("Std_CloseActiveWindow")
{
sGroup = "Window";
sMenuText = QT_TR_NOOP("Cl&ose");
sMenuText = QT_TR_NOOP("&Close");
sToolTipText = QT_TR_NOOP("Close active window");
sWhatsThis = "Std_CloseActiveWindow";
sStatusTip = QT_TR_NOOP("Close active window");
@@ -141,7 +141,7 @@ StdCmdCloseAllWindows::StdCmdCloseAllWindows()
: Command("Std_CloseAllWindows")
{
sGroup = "Window";
sMenuText = QT_TR_NOOP("Close Al&l");
sMenuText = QT_TR_NOOP("Close A&ll");
sToolTipText = QT_TR_NOOP("Close all windows");
sWhatsThis = "Std_CloseAllWindows";
sStatusTip = QT_TR_NOOP("Close all windows");
@@ -169,7 +169,7 @@ StdCmdActivateNextWindow::StdCmdActivateNextWindow()
: Command("Std_ActivateNextWindow")
{
sGroup = "Window";
sMenuText = QT_TR_NOOP("Ne&xt");
sMenuText = QT_TR_NOOP("&Next");
sToolTipText = QT_TR_NOOP("Activate next window");
sWhatsThis = "Std_ActivateNextWindow";
sStatusTip = QT_TR_NOOP("Activate next window");
@@ -198,7 +198,7 @@ StdCmdActivatePrevWindow::StdCmdActivatePrevWindow()
: Command("Std_ActivatePrevWindow")
{
sGroup = "Window";
sMenuText = QT_TR_NOOP("Pre&vious");
sMenuText = QT_TR_NOOP("&Previous");
sToolTipText = QT_TR_NOOP("Activate previous window");
sWhatsThis = "Std_ActivatePrevWindow";
sStatusTip = QT_TR_NOOP("Activate previous window");
@@ -278,7 +278,7 @@ StdCmdDockViewMenu::StdCmdDockViewMenu()
: Command("Std_DockViewMenu")
{
sGroup = "View";
sMenuText = QT_TR_NOOP("Panels");
sMenuText = QT_TR_NOOP("&Panels");
sToolTipText = QT_TR_NOOP("List of available dock panels");
sWhatsThis = "Std_DockViewMenu";
sStatusTip = QT_TR_NOOP("List of available dock panels");
@@ -314,7 +314,7 @@ StdCmdToolBarMenu::StdCmdToolBarMenu()
: Command("Std_ToolBarMenu")
{
sGroup = "View";
sMenuText = QT_TR_NOOP("Tool&bars");
sMenuText = QT_TR_NOOP("&Toolbars");
sToolTipText = QT_TR_NOOP("Toggles this window");
sWhatsThis = "Std_ToolBarMenu";
sStatusTip = QT_TR_NOOP("Toggles this window");
+43 -21
View File
@@ -534,6 +534,40 @@ void AboutDialog::linkActivated(const QUrl& link)
licenseView->setSource(link);
}
void AboutDialog::addModuleInfo(QTextStream& str, const QString& modPath, bool& firstMod)
{
QFileInfo mod(modPath);
if (mod.isHidden()) { // Ignore hidden directories
return;
}
if (firstMod) {
firstMod = false;
str << "Installed mods: \n";
}
str << " * " << (mod.isDir() ? QDir(modPath).dirName() : mod.fileName());
try {
auto metadataFile =
boost::filesystem::path(mod.absoluteFilePath().toStdString()) / "package.xml";
if (boost::filesystem::exists(metadataFile)) {
App::Metadata metadata(metadataFile);
if (metadata.version() != App::Meta::Version()) {
str << QLatin1String(" ") + QString::fromStdString(metadata.version().str());
}
}
}
catch (const Base::Exception& e) {
auto what = QString::fromUtf8(e.what()).trimmed().replace(QChar::fromLatin1('\n'),
QChar::fromLatin1(' '));
str << " (Malformed metadata: " << what << ")";
}
QFileInfo disablingFile(mod.absoluteFilePath(), QString::fromLatin1("ADDON_DISABLED"));
if (disablingFile.exists()) {
str << " (Disabled)";
}
str << "\n";
}
void AboutDialog::copyToClipboard()
{
QString data;
@@ -680,28 +714,16 @@ void AboutDialog::copyToClipboard()
bool firstMod = true;
if (fs::exists(modDir) && fs::is_directory(modDir)) {
for (const auto& mod : fs::directory_iterator(modDir)) {
auto dirName = mod.path().filename().string();
if (dirName[0] == '.') { // Ignore dot directories
continue;
}
if (firstMod) {
firstMod = false;
str << "Installed mods: \n";
}
str << " * " << QString::fromStdString(mod.path().filename().string());
auto metadataFile = mod.path() / "package.xml";
if (fs::exists(metadataFile)) {
App::Metadata metadata(metadataFile);
if (metadata.version() != App::Meta::Version()) {
str << QLatin1String(" ") + QString::fromStdString(metadata.version().str());
}
}
auto disablingFile = mod.path() / "ADDON_DISABLED";
if (fs::exists(disablingFile)) {
str << " (Disabled)";
}
auto dirName = mod.path().string();
addModuleInfo(str, QString::fromStdString(dirName), firstMod);
}
}
auto additionalModules = config.find("AdditionalModulePaths");
str << "\n";
if (additionalModules != config.end()) {
auto mods = QString::fromStdString(additionalModules->second).split(QChar::fromLatin1(';'));
for (const auto& mod : mods) {
addModuleInfo(str, mod, firstMod);
}
}
+2
View File
@@ -26,6 +26,7 @@
#include <QDialog>
#include <QTextBrowser>
#include <Gui/MDIView.h>
#include <qlocale.h>
namespace Gui
{
@@ -88,6 +89,7 @@ protected:
void showCollectionInformation();
void showPrivacyPolicy();
void showOrHideImage(const QRect& rect);
void addModuleInfo(QTextStream& inout_str, const QString& modPath, bool& inout_first);
protected:
QPixmap aboutImage() const;
+1 -1
View File
@@ -121,7 +121,7 @@ DlgCheckableMessageBox::DlgCheckableMessageBox(QWidget *parent) :
m_d->ui.setupUi(this);
m_d->ui.pixmapLabel->setVisible(false);
connect(m_d->ui.buttonBox, &QDialogButtonBox::accepted, this, &DlgCheckableMessageBox::accept);
connect(m_d->ui.buttonBox, &QDialogButtonBox::rejected, this, &DlgCheckableMessageBox::reject);
connect(m_d->ui.buttonBox, &QDialogButtonBox::rejected, this, &DlgCheckableMessageBox::reject);
connect(m_d->ui.buttonBox, &QDialogButtonBox::clicked,
this, &DlgCheckableMessageBox::slotClicked);
}
+10 -3
View File
@@ -32,6 +32,13 @@
<item>
<widget class="QLineEdit" name="lineEdit"/>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
@@ -39,12 +46,12 @@
<property name="columnCount">
<number>1</number>
</property>
<attribute name="headerMinimumSectionSize">
<number>50</number>
</attribute>
<attribute name="headerDefaultSectionSize">
<number>250</number>
</attribute>
<attribute name="headerMinimumSectionSize">
<number>50</number>
</attribute>
<attribute name="headerShowSortIndicator" stdset="0">
<bool>true</bool>
</attribute>
+12
View File
@@ -32,6 +32,7 @@
#include "DlgCreateNewPreferencePackImp.h"
#include "ui_DlgCreateNewPreferencePack.h"
#include "FileDialog.h"
using namespace Gui::Dialog;
@@ -54,6 +55,7 @@ DlgCreateNewPreferencePackImp::DlgCreateNewPreferencePackImp(QWidget* parent)
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
connect(ui->treeWidget, &QTreeWidget::itemChanged, this, &DlgCreateNewPreferencePackImp::onItemChanged);
connect(ui->lineEdit, &QLineEdit::textEdited, this, &DlgCreateNewPreferencePackImp::onLineEditTextEdited);
connect(ui->pushButton, &QPushButton::clicked, this, &DlgCreateNewPreferencePackImp::onBrowseButtonClicked);
}
@@ -114,6 +116,11 @@ std::string DlgCreateNewPreferencePackImp::preferencePackName() const
return ui->lineEdit->text().toStdString();
}
std::string Gui::Dialog::DlgCreateNewPreferencePackImp::preferencePackDirectory() const
{
return _cfgFileDirectory.toStdString();
}
void DlgCreateNewPreferencePackImp::onItemChanged(QTreeWidgetItem* item, int column)
{
Q_UNUSED(column);
@@ -151,6 +158,11 @@ void DlgCreateNewPreferencePackImp::onLineEditTextEdited(const QString& text)
ui->buttonBox->button(QDialogButtonBox::Ok)->setDisabled(text.isEmpty());
}
void DlgCreateNewPreferencePackImp::onBrowseButtonClicked()
{
_cfgFileDirectory = FileDialog::getExistingDirectory(this, tr("Export Config"), _cfgFileDirectory);
}
void Gui::Dialog::DlgCreateNewPreferencePackImp::accept()
{
// Ensure that the chosen name is either unique, or that the user actually wants to overwrite the old one
+4
View File
@@ -59,6 +59,7 @@ public:
std::vector<PreferencePackManager::TemplateFile> selectedTemplates() const;
std::string preferencePackName() const;
std::string preferencePackDirectory() const;
protected Q_SLOTS:
@@ -66,6 +67,8 @@ protected Q_SLOTS:
void onLineEditTextEdited(const QString &text);
void onBrowseButtonClicked();
void accept() override;
private:
@@ -74,6 +77,7 @@ private:
std::vector<PreferencePackManager::TemplateFile> _templates;
QRegularExpressionValidator _nameValidator;
std::vector<std::string> _existingPackNames;
QString _cfgFileDirectory;
};
} // namespace Dialog
+13 -13
View File
@@ -28,6 +28,8 @@
#include <QTreeWidget>
#endif
#include <fmt/format.h>
#include <App/Application.h>
#include <App/Document.h>
#include <App/DocumentObject.h>
@@ -174,7 +176,7 @@ Base::Type DlgExpressionInput::determineTypeVarSet()
// varset. Since unit properties are derived from App::PropertyFloat, it
// allows us to create a property and set the value.
std::string unitTypeString = impliedUnit.getTypeString().toStdString();
std::string unitTypeString = impliedUnit.getTypeString();
if (unitTypeString.empty()) {
// no type was provided
return Base::Type::badType();
@@ -187,7 +189,7 @@ Base::Type DlgExpressionInput::determineTypeVarSet()
bool DlgExpressionInput::typeOkForVarSet()
{
std::string unitType = impliedUnit.getTypeString().toStdString();
std::string unitType = impliedUnit.getTypeString();
return determineTypeVarSet() != Base::Type::badType();
}
@@ -242,12 +244,10 @@ void NumberRange::throwIfOutOfRange(const Base::Quantity& value) const
if (value.getValue() < minimum || value.getValue() > maximum) {
Base::Quantity minVal(minimum, value.getUnit());
Base::Quantity maxVal(maximum, value.getUnit());
QString valStr = value.getUserString();
QString minStr = minVal.getUserString();
QString maxStr = maxVal.getUserString();
QString error = QString::fromLatin1("Value out of range (%1 out of [%2, %3])").arg(valStr, minStr, maxStr);
throw Base::ValueError(error.toStdString());
auto valStr = value.getUserString();
auto minStr = minVal.getUserString();
auto maxStr = maxVal.getUserString();
throw Base::ValueError(fmt::format("Value out of range ({} out of [{}, {}])", valStr, minStr, maxStr));
}
}
@@ -289,12 +289,12 @@ void DlgExpressionInput::checkExpression(const QString& text)
auto * n = Base::freecad_dynamic_cast<NumberExpression>(result.get());
if (n) {
Base::Quantity value = n->getQuantity();
QString msg = value.getUserString();
if (!value.isValid()) {
throw Base::ValueError("Not a number");
}
else if (!impliedUnit.isEmpty()) {
auto msg = value.getUserString();
if (!impliedUnit.isEmpty()) {
if (!value.getUnit().isEmpty() && value.getUnit() != impliedUnit)
throw Base::UnitsMismatchError("Unit mismatch between result and required unit");
@@ -302,7 +302,7 @@ void DlgExpressionInput::checkExpression(const QString& text)
}
else if (!value.getUnit().isEmpty()) {
msg += QString::fromUtf8(" (Warning: unit discarded)");
msg += " (Warning: unit discarded)";
QPalette p(ui->msg->palette());
p.setColor(QPalette::WindowText, Qt::red);
@@ -311,7 +311,7 @@ void DlgExpressionInput::checkExpression(const QString& text)
numberRange.throwIfOutOfRange(value);
ui->msg->setText(msg);
ui->msg->setText(QString::fromStdString(msg));
}
else {
ui->msg->setText(QString::fromStdString(result->toString()));
+44 -27
View File
@@ -60,14 +60,30 @@ namespace Dialog
class MacroItem: public QTreeWidgetItem
{
public:
MacroItem(QTreeWidget* widget, bool systemwide)
MacroItem(QTreeWidget* widget, bool systemwide, const QString& dirPath)
: QTreeWidgetItem(widget)
, systemWide(systemwide)
, dirPath(dirPath)
{}
/**
* Acts same as setText method but additionally set toolTip with text of
* absolute file path. There may be different macros with same names from
* different system paths. So it could be helpful for user to show where
* exactly macro is placed.
*/
void setFileName(int column, const QString& text)
{
QFileInfo file(dirPath, text);
setToolTip(column, file.absoluteFilePath());
return QTreeWidgetItem::setText(column, text);
}
~MacroItem() override = default;
bool systemWide;
QString dirPath;
};
} // namespace Dialog
} // namespace Gui
@@ -229,23 +245,37 @@ QStringList DlgMacroExecuteImp::filterFiles(const QString& folder)
* Fills up the list with macro files found in the specified location
* that have been filtered by both filename and by content
*/
void DlgMacroExecuteImp::fillUpListForDir(const QString& dirPath, bool systemWide)
{
QStringList filteredByContent = this->filterFiles(dirPath);
ui->userMacroListBox->clear();
for (auto& fn : filteredByContent) {
auto* parent = systemWide ? ui->systemMacroListBox : ui->userMacroListBox;
auto item = new MacroItem(parent, systemWide, dirPath);
item->setFileName(0, fn);
}
}
/**
* Fills up the list with macro files found in all system paths and specified by
* user location that have been filtered by both filename and by content
*/
void DlgMacroExecuteImp::fillUpList()
{
QStringList filteredByContent = this->filterFiles(this->macroPath);
ui->userMacroListBox->clear();
for (auto fn : filteredByContent) {
auto item = new MacroItem(ui->userMacroListBox, false);
item->setText(0, fn);
}
fillUpListForDir(this->macroPath, false);
QString dirstr =
QString::fromStdString(App::Application::getHomePath()) + QString::fromLatin1("Macro");
filteredByContent = this->filterFiles(dirstr);
fillUpListForDir(dirstr, true);
ui->systemMacroListBox->clear();
for (auto fn : filteredByContent) {
auto item = new MacroItem(ui->systemMacroListBox, true);
item->setText(0, fn);
auto& config = App::Application::Config();
auto additionalMacros = config.find("AdditionalMacroPaths");
if (additionalMacros != config.end()) {
QString dirsstrs = QString::fromStdString(additionalMacros->second);
QStringList dirs = dirsstrs.split(QChar::fromLatin1(';'));
for (const auto& dirstr : dirs) {
fillUpListForDir(dirstr, true);
}
}
}
@@ -392,17 +422,7 @@ void DlgMacroExecuteImp::accept()
auto mitem = static_cast<MacroItem*>(item);
QDir dir;
if (!mitem->systemWide) {
dir = QDir(this->macroPath);
}
else {
QString dirstr =
QString::fromStdString(App::Application::getHomePath()) + QString::fromLatin1("Macro");
dir = QDir(dirstr);
}
QDir dir(mitem->dirPath);
QFileInfo fi(dir, item->text(0));
try {
getMainWindow()->setCursor(Qt::WaitCursor);
@@ -444,19 +464,15 @@ void DlgMacroExecuteImp::onFileChooserFileNameChanged(const QString& fn)
*/
void DlgMacroExecuteImp::onEditButtonClicked()
{
QDir dir;
QTreeWidgetItem* item = nullptr;
int index = ui->tabMacroWidget->currentIndex();
if (index == 0) { // user-specific
item = ui->userMacroListBox->currentItem();
dir.setPath(this->macroPath);
}
else {
// index == 1 system-wide
item = ui->systemMacroListBox->currentItem();
dir.setPath(QString::fromStdString(App::Application::getHomePath())
+ QString::fromLatin1("Macro"));
}
if (!item) {
@@ -464,6 +480,7 @@ void DlgMacroExecuteImp::onEditButtonClicked()
}
auto mitem = static_cast<MacroItem*>(item);
QDir dir(mitem->dirPath);
QString file = QString::fromLatin1("%1/%2").arg(dir.absolutePath(), item->text(0));
auto editor = new PythonEditor();
+1
View File
@@ -69,6 +69,7 @@ private:
protected:
void fillUpList();
void fillUpListForDir(const QString& dirPath, bool systemWide);
QStringList filterFiles(const QString&);
protected:
+35 -1
View File
@@ -289,7 +289,9 @@ PreferencePage* DlgPreferencesImp::createPreferencePage(const std::string& pageN
auto resetMargins = [](QWidget* widget) {
widget->setContentsMargins(0, 0, 0, 0);
widget->layout()->setContentsMargins(0, 0, 0, 0);
if (auto layout = widget->layout()) {
layout->setContentsMargins(0, 0, 0, 0);
}
};
// settings layout already takes care for margins, we need to reset everything to 0
@@ -503,6 +505,38 @@ void DlgPreferencesImp::activateGroupPage(const QString& group, int index)
}
}
/**
* Activates the page with name \a pageName of the group with name \a group.
*/
void DlgPreferencesImp::activateGroupPageByPageName(const QString& group, const QString& pageName)
{
for (int i = 0; i < ui->groupWidgetStack->count(); i++) {
auto* pageStackWidget = qobject_cast<QStackedWidget*>(ui->groupWidgetStack->widget(i));
if (!pageStackWidget) {
continue;
}
if (pageStackWidget->property(GroupNameProperty).toString() == group) {
ui->groupWidgetStack->setCurrentWidget(pageStackWidget);
for (int pageIdx = 0; pageIdx < pageStackWidget->count(); pageIdx++) {
auto page = qobject_cast<PreferencePage*>(pageStackWidget->widget(pageIdx));
if (page) {
if (page->property(PageNameProperty).toString() == pageName) {
pageStackWidget->setCurrentIndex(pageIdx);
break;
}
}
}
updatePageDependentWidgets();
return;
}
}
}
/**
* Returns the group name \a group and position \a index of the active page.
*/
+1
View File
@@ -149,6 +149,7 @@ public:
void reject() override;
void reload();
void activateGroupPage(const QString& group, int index);
void activateGroupPageByPageName(const QString& group, const QString& pageName);
void activeGroupPage(QString& group, int& index) const;
protected:
+7 -6
View File
@@ -105,7 +105,7 @@ DlgUnitsCalculator::DlgUnitsCalculator(QWidget* parent, Qt::WindowFlags fl)
<< Base::Unit::Volume << Base::Unit::VolumeFlowRate
<< Base::Unit::VolumetricThermalExpansionCoefficient << Base::Unit::Work;
for (const Base::Unit& it : units) {
ui->unitsBox->addItem(it.getTypeString());
ui->unitsBox->addItem(QString::fromStdString(it.getTypeString()));
}
ui->quantitySpinBox->setValue(1.0);
@@ -138,20 +138,21 @@ void DlgUnitsCalculator::valueChanged(const Base::Quantity& quant)
// explicitly check for "ee" like in "eeV" because this would trigger an exception in Base::Unit
// since it expects then a scientific notation number like "1e3"
if ((ui->UnitInput->text().mid(0, 2) == QString::fromLatin1("ee"))
|| Base::Unit(ui->UnitInput->text()).getTypeString().isEmpty()) {
|| Base::Unit(ui->UnitInput->text().toStdString()).getTypeString().empty()) {
ui->ValueOutput->setText(
QString::fromLatin1("%1 %2").arg(tr("unknown unit:"), ui->UnitInput->text()));
ui->pushButton_Copy->setEnabled(false);
}
else { // the unit is valid
// we can only convert units of the same type, thus check
if (Base::Unit(ui->UnitInput->text()).getTypeString() != quant.getUnit().getTypeString()) {
if (Base::Unit(ui->UnitInput->text().toStdString()).getTypeString()
!= quant.getUnit().getTypeString()) {
ui->ValueOutput->setText(tr("unit mismatch"));
ui->pushButton_Copy->setEnabled(false);
}
else { // the unit is valid and has the same type
double convertValue =
Base::Quantity::parse(QString::fromLatin1("1") + ui->UnitInput->text()).getValue();
Base::Quantity::parse("1" + ui->UnitInput->text().toStdString()).getValue();
// we got now e.g. for "1 in" the value '25.4' because 1 in = 25.4 mm
// the result is now just quant / convertValue because the input is always in a base
// unit (an input of "1 cm" will immediately be converted to "10 mm" by Gui::InputField
@@ -201,11 +202,11 @@ void DlgUnitsCalculator::onUnitsBoxActivated(int index)
// SI units use [m], not [mm] for lengths
//
Base::Quantity q = ui->quantitySpinBox->value();
int32_t old = q.getUnit().getSignature().Length;
int32_t old = q.getUnit().length();
double value = q.getValue();
Base::Unit unit = units[index];
int32_t len = unit.getSignature().Length;
int32_t len = unit.length();
ui->quantitySpinBox->setValue(Base::Quantity(value * std::pow(10.0, 3 * (len - old)), unit));
}
+1 -1
View File
@@ -340,7 +340,7 @@ void DocumentRecovery::accept()
}
}
d->ui.buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Finish"));
d->ui.buttonBox->button(QDialogButtonBox::Ok)->setText(tr("&Finish"));
d->ui.buttonBox->button(QDialogButtonBox::Cancel)->setEnabled(false);
d->recovered = true;
}
+3 -3
View File
@@ -180,10 +180,10 @@ void EditableDatumLabel::stopEdit()
Base::Quantity quantity = spinBox->value();
double factor{};
QString unitStr;
QString valueStr;
std::string unitStr;
std::string valueStr;
valueStr = quantity.getUserString(factor, unitStr);
label->string = SbString(valueStr.toUtf8().constData());
label->string = SbString(valueStr.c_str());
spinBox->deleteLater();
spinBox = nullptr;
+35 -41
View File
@@ -169,10 +169,10 @@ void InputField::updateText(const Base::Quantity& quant)
}
double dFactor;
QString unitStr;
QString txt = quant.getUserString(dFactor, unitStr);
std::string unitStr;
std::string txt = quant.getUserString(dFactor, unitStr);
actUnitValue = quant.getValue()/dFactor;
setText(txt);
setText(QString::fromStdString(txt));
}
void InputField::resizeEvent(QResizeEvent *)
@@ -256,7 +256,7 @@ void InputField::newInput(const QString & text)
}
}
else
res = Quantity::parse(input);
res = Quantity::parse(input.toStdString());
}
catch(Base::Exception &e){
QString errorText = QString::fromLatin1(e.what());
@@ -292,7 +292,7 @@ void InputField::newInput(const QString & text)
}
double dFactor;
QString unitStr;
std::string unitStr;
res.getUserString(dFactor, unitStr);
actUnitValue = res.getValue()/dFactor;
// Preserve previous format
@@ -456,7 +456,7 @@ const Base::Unit& InputField::getUnit() const
/// get stored, valid quantity as a string
QString InputField::getQuantityString() const
{
return actQuantity.getUserString();
return QString::fromStdString(actQuantity.getUserString());
}
/// set, validate and display quantity from a string. Must match existing units.
@@ -471,18 +471,18 @@ void InputField::setQuantityString(const QString& text)
QString InputField::rawText() const
{
double factor;
QString unit;
std::string unit;
double value = actQuantity.getValue();
actQuantity.getUserString(factor, unit);
return QString::fromLatin1("%1 %2").arg(value / factor).arg(unit);
return QString::fromLatin1("%1 %2").arg(value / factor).arg(QString::fromStdString(unit));
}
/// expects the string in C locale and internally converts it into the OS-specific locale
void InputField::setRawText(const QString& text)
{
Base::Quantity quant = Base::Quantity::parse(text);
Base::Quantity quant = Base::Quantity::parse(text.toStdString());
// Input and then format the quantity
newInput(quant.getUserString());
newInput(QString::fromStdString(quant.getUserString()));
updateText(actQuantity);
}
@@ -533,7 +533,7 @@ void InputField::setMinimum(double m)
void InputField::setUnitText(const QString& str)
{
try {
Base::Quantity quant = Base::Quantity::parse(str);
Base::Quantity quant = Base::Quantity::parse(str.toStdString());
setUnit(quant.getUnit());
}
catch (...) {
@@ -544,9 +544,9 @@ void InputField::setUnitText(const QString& str)
QString InputField::getUnitText()
{
double dFactor;
QString unitStr;
std::string unitStr;
actQuantity.getUserString(dFactor, unitStr);
return unitStr;
return QString::fromStdString(unitStr);
}
int InputField::getPrecision() const
@@ -632,11 +632,11 @@ void InputField::focusInEvent(QFocusEvent *event)
void InputField::focusOutEvent(QFocusEvent *event)
{
try {
if (Quantity::parse(this->text()).getUnit().isEmpty()) {
if (Quantity::parse(this->text().toStdString()).getUnit().isEmpty()) {
// if user didn't enter a unit, we virtually compensate
// the multiplication factor induced by user unit system
double factor;
QString unitStr;
std::string unitStr;
actQuantity.getUserString(factor, unitStr);
actQuantity = actQuantity * factor;
}
@@ -644,7 +644,7 @@ void InputField::focusOutEvent(QFocusEvent *event)
catch (const Base::ParserError&) {
// do nothing, let apply the last known good value
}
this->setText(actQuantity.getUserString());
this->setText(QString::fromStdString(actQuantity.getUserString()));
QLineEdit::focusOutEvent(event);
}
@@ -655,35 +655,29 @@ void InputField::keyPressEvent(QKeyEvent *event)
return;
}
double val = actUnitValue;
switch (event->key()) {
case Qt::Key_Up:
{
double val = actUnitValue + StepSize;
if (val > Maximum)
val = Maximum;
double dFactor;
QString unitStr;
actQuantity.getUserString(dFactor, unitStr);
this->setText(QString::fromUtf8("%L1 %2").arg(val).arg(unitStr));
event->accept();
}
val += StepSize;
if (val > Maximum)
val = Maximum;
break;
case Qt::Key_Down:
{
double val = actUnitValue - StepSize;
if (val < Minimum)
val = Minimum;
double dFactor;
QString unitStr;
actQuantity.getUserString(dFactor, unitStr);
this->setText(QString::fromUtf8("%L1 %2").arg(val).arg(unitStr));
event->accept();
}
val -= StepSize;
if (val < Minimum)
val = Minimum;
break;
default:
QLineEdit::keyPressEvent(event);
break;
return;
}
double dFactor;
std::string unitStr;
actQuantity.getUserString(dFactor, unitStr);
this->setText(QString::fromUtf8("%L1 %2").arg(val).arg(QString::fromStdString(unitStr)));
event->accept();
}
void InputField::wheelEvent (QWheelEvent * event)
@@ -705,10 +699,10 @@ void InputField::wheelEvent (QWheelEvent * event)
val = Minimum;
double dFactor;
QString unitStr;
std::string unitStr;
actQuantity.getUserString(dFactor, unitStr);
this->setText(QString::fromUtf8("%L1 %2").arg(val).arg(unitStr));
this->setText(QString::fromUtf8("%L1 %2").arg(val).arg(QString::fromStdString(unitStr)));
selectNumber();
event->accept();
}
@@ -737,10 +731,10 @@ QValidator::State InputField::validate(QString& input, int& pos) const
Quantity res;
QString text = input;
fixup(text);
res = Quantity::parse(text);
res = Quantity::parse(text.toStdString());
double factor;
QString unitStr;
std::string unitStr;
res.getUserString(factor, unitStr);
double value = res.getValue()/factor;
// disallow to enter numbers out of range
+12 -8
View File
@@ -51,11 +51,10 @@
#endif
#include "SoAxisCrossKit.h"
#include "SoDevicePixelRatioElement.h"
using namespace Gui;
SO_KIT_SOURCE(SoShapeScale)
// Constructor.
@@ -85,24 +84,29 @@ SoShapeScale::initClass()
void
SoShapeScale::GLRender(SoGLRenderAction * action)
{
SoState * state = action->getState();
SoScale * scale = static_cast<SoScale*>(this->getAnyPart(SbName("scale"), true));
auto* scale = static_cast<SoScale*>(this->getAnyPart(SbName("scale"), true));
if (!this->active.getValue()) {
SbVec3f v(1.0f, 1.0f, 1.0f);
if (scale->scaleFactor.getValue() != v)
if (scale->scaleFactor.getValue() != v){
scale->scaleFactor = v;
}
}
else {
SoState* state = action->getState();
const SbViewportRegion & vp = SoViewportRegionElement::get(state);
const SbViewVolume & vv = SoViewVolumeElement::get(state);
SbVec3f center(0.0f, 0.0f, 0.0f);
float nsize = this->scaleFactor.getValue() / float(vp.getViewportSizePixels()[1]);
float nsize = this->scaleFactor.getValue() / float(vp.getViewportSizePixels()[0]);
SoModelMatrixElement::get(state).multVecMatrix(center, center); // world coords
float sf = vv.getWorldToScreenScale(center, nsize);
sf *= SoDevicePixelRatioElement::get(state);
SbVec3f v(sf, sf, sf);
if (scale->scaleFactor.getValue() != v)
if (scale->scaleFactor.getValue() != v){
scale->scaleFactor = v;
}
}
inherited::GLRender(action);
+2 -2
View File
@@ -33,11 +33,11 @@ namespace Gui
/**
* @class SoFCTransform
* @brief A temporary workaround for coin3d/coin#534.
*
*
* This class is a workaround for a missing feature to reduce the OpenGL stack size.
* The issue was reported here: https://github.com/coin3d/coin/issues/534
* And was merged here: https://github.com/coin3d/coin/pull/535
*
*
* Once this feature is available in all supported versions of Coin3D, this class should
* be removed and all instances should revert to using SoTransform.
*/
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -322,7 +322,7 @@ StdCmdPythonHelp::StdCmdPythonHelp()
, server(nullptr)
{
sGroup = "Tools";
sMenuText = QT_TR_NOOP("Automatic Python Modules Documentation");
sMenuText = QT_TR_NOOP("Automatic Python &Modules Documentation");
sToolTipText = QT_TR_NOOP("Opens the Python Modules documentation");
sWhatsThis = "Std_PythonHelp";
sStatusTip = sToolTipText;
+12 -5
View File
@@ -504,12 +504,11 @@ static void copyTemplateParameters(/*const*/ ParameterManager& templateParameter
}
}
void PreferencePackManager::save(const std::string& name, const std::vector<TemplateFile>& templates)
void PreferencePackManager::save(const std::string& name, const std::string& directory, const std::vector<TemplateFile>& templates)
{
if (templates.empty())
return;
AddPackToMetadata(name);
// Create the config file
auto outputParameterManager = ParameterManager::Create();
@@ -519,9 +518,17 @@ void PreferencePackManager::save(const std::string& name, const std::vector<Temp
templateParameterManager->LoadDocument(Base::FileInfo::pathToString(t.path).c_str());
copyTemplateParameters(*templateParameterManager, *outputParameterManager);
}
auto savedPreferencePacksDirectory = getSavedPreferencePacksPath();
auto cfgFilename = savedPreferencePacksDirectory / name / (name + ".cfg");
outputParameterManager->SaveDocument(Base::FileInfo::pathToString(cfgFilename).c_str());
std::string cfgFilename;
if (directory.empty()) {
AddPackToMetadata(name);
auto savedPreferencePacksDirectory = getSavedPreferencePacksPath();
cfgFilename = Base::FileInfo::pathToString(savedPreferencePacksDirectory / name / (name + ".cfg"));
}
else {
cfgFilename = Base::FileInfo::pathToString(fs::path(directory) / (name + ".cfg"));
}
outputParameterManager->SaveDocument(cfgFilename.c_str());
}
static std::vector<fs::path> scanForTemplateFolders(const std::string& groupName, const fs::path& entry)
+1 -1
View File
@@ -176,7 +176,7 @@ namespace Gui {
*
* If the named preferencePack does not exist, this creates it on disk. If it does exist, this overwrites the original.
*/
void save(const std::string& name, const std::vector<TemplateFile>& templates);
void save(const std::string& name, const std::string& directory, const std::vector<TemplateFile>& templates);
std::vector<TemplateFile> templateFiles(bool rescan = false);

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