diff --git a/.github/workflows/CI_master.yml b/.github/workflows/CI_master.yml index 203a035daa3b..eda064824c31 100644 --- a/.github/workflows/CI_master.yml +++ b/.github/workflows/CI_master.yml @@ -57,11 +57,11 @@ jobs: with: artifactBasename: Ubuntu_20-04-${{ github.run_id }} - Ubuntu_22-04_Conda: + Ubuntu_24-04_Conda: needs: [Prepare] - uses: ./.github/workflows/sub_buildUbuntu2204Conda.yml + uses: ./.github/workflows/sub_buildUbuntu2404Conda.yml with: - artifactBasename: Ubuntu_22-04_Conda-${{ github.run_id }} + artifactBasename: Ubuntu_24-04_Conda-${{ github.run_id }} Windows: needs: [Prepare] @@ -84,7 +84,7 @@ jobs: Pixi, MacOS_13_Conda_Apple, Ubuntu_20-04, - Ubuntu_22-04_Conda, + Ubuntu_24-04_Conda, Windows, Lint ] diff --git a/.github/workflows/sub_buildUbuntu2204Conda.yml b/.github/workflows/sub_buildUbuntu2404Conda.yml similarity index 99% rename from .github/workflows/sub_buildUbuntu2204Conda.yml rename to .github/workflows/sub_buildUbuntu2404Conda.yml index e9009aece47c..b62394aed081 100644 --- a/.github/workflows/sub_buildUbuntu2204Conda.yml +++ b/.github/workflows/sub_buildUbuntu2404Conda.yml @@ -24,7 +24,7 @@ # This is a build and test workflow for CI of FreeCAD. # This workflow aims at building and testing FreeCAD on a Conda environment on Linux. -name: Build Ubuntu 22.04 (Conda) +name: Build Ubuntu 24.04 (Conda) on: workflow_call: inputs: @@ -45,7 +45,7 @@ on: jobs: Build: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 continue-on-error: ${{ inputs.allowedToFail }} env: CCACHE_DIR: ${{ github.workspace }}/ccache diff --git a/CMakeLists.txt b/CMakeLists.txt index c6c3bc84b289..b793fc21fee2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,7 +31,7 @@ project(FreeCAD) set(PACKAGE_VERSION_MAJOR "1") set(PACKAGE_VERSION_MINOR "0") -set(PACKAGE_VERSION_PATCH "1") # number of patch release (e.g. "4" for the 0.18.4 release) +set(PACKAGE_VERSION_PATCH "2") # number of patch release (e.g. "4" for the 0.18.4 release) set(PACKAGE_VERSION_SUFFIX "") # either "dev" for development snapshot or "" (empty string) set(PACKAGE_BUILD_VERSION "0") # used when the same FreeCAD version will be re-released (for example using an updated LibPack) diff --git a/cMake/FindOCC.cmake b/cMake/FindOCC.cmake index c72066f43e2f..c81bd4fe898c 100644 --- a/cMake/FindOCC.cmake +++ b/cMake/FindOCC.cmake @@ -140,6 +140,9 @@ if(OCC_FOUND) TKHLR TKFeat ) + if (OCC_VERSION_STRING VERSION_GREATER_EQUAL 7.9.0) + list(APPEND OCC_LIBRARIES TKExpress) + endif () set(OCC_OCAF_LIBRARIES TKBin TKBinL diff --git a/conda/environment.devenv.yml b/conda/environment.devenv.yml index 151ba52dd8fb..c15efbe59e3a 100644 --- a/conda/environment.devenv.yml +++ b/conda/environment.devenv.yml @@ -3,63 +3,67 @@ channels: - conda-forge dependencies: - conda-forge/noarch::conda-libmamba-solver==24.7.0 -- libspnav # [linux] -- kernel-headers_linux-64 # [linux and x86_64] -- libdrm-cos7-x86_64 # [linux and x86_64] -- libselinux-cos7-x86_64 # [linux and x86_64] -- libsepol-cos7-x86_64 # [linux and x86_64] -- libx11-common-cos7-x86_64 # [linux and x86_64] -- libx11-cos7-x86_64 # [linux and x86_64] -- libxau-cos7-x86_64 # [linux and x86_64] -- libxcb-cos7-x86_64 # [linux and x86_64] -- libxdamage-cos7-x86_64 # [linux and x86_64] -- libxext-cos7-x86_64 # [linux and x86_64] -- libxfixes-cos7-x86_64 # [linux and x86_64] -- libxi-cos7-x86_64 # [linux and x86_64] -- libxi-devel-cos7-x86_64 # [linux and x86_64] -- libxxf86vm-cos7-x86_64 # [linux and x86_64] -- mesa-dri-drivers-cos7-x86_64 # [linux and x86_64] -- mesa-libegl-cos7-x86_64 # [linux and x86_64] -- mesa-libegl-devel-cos7-x86_64 # [linux and x86_64] -- mesa-libgl-cos7-x86_64 # [linux and x86_64] -- mesa-libgl-devel-cos7-x86_64 # [linux and x86_64] -- pixman-cos7-x86_64 # [linux and x86_64] -- sysroot_linux-64 # [linux and x86_64] -- xorg-x11-server-common-cos7-x86_64 # [linux and x86_64] -- xorg-x11-server-xvfb-cos7-x86_64 # [linux and x86_64] -- kernel-headers_linux-aarch64 # [linux and aarch64] -- libdrm-cos7-aarch64 # [linux and aarch64] -- libglvnd-cos7-aarch64 # [linux and aarch64] -- libglvnd-glx-cos7-aarch64 # [linux and aarch64] -- libselinux-cos7-aarch64 # [linux and aarch64] -- libsepol-cos7-aarch64 # [linux and aarch64] -- libx11-common-cos7-aarch64 # [linux and aarch64] -- libx11-cos7-aarch64 # [linux and aarch64] -- libxau-cos7-aarch64 # [linux and aarch64] -- libxcb-cos7-aarch64 # [linux and aarch64] -- libxdamage-cos7-aarch64 # [linux and aarch64] -- libxext-cos7-aarch64 # [linux and aarch64] -- libxfixes-cos7-aarch64 # [linux and aarch64] -- libxi-cos7-aarch64 # [linux and aarch64] -- libxi-devel-cos7-aarch64 # [linux and aarch64] -- libxxf86vm-cos7-aarch64 # [linux and aarch64] -- mesa-dri-drivers-cos7-aarch64 # [linux and aarch64] -- mesa-khr-devel-cos7-aarch64 # [linux and aarch64] -- mesa-libegl-cos7-aarch64 # [linux and aarch64] -- mesa-libegl-devel-cos7-aarch64 # [linux and aarch64] -- mesa-libgbm-cos7-aarch64 # [linux and aarch64] -- mesa-libgl-cos7-aarch64 # [linux and aarch64] -- mesa-libgl-devel-cos7-aarch64 # [linux and aarch64] -- mesa-libglapi-cos7-aarch64 # [linux and aarch64] -- pixman-cos7-aarch64 # [linux and aarch64] -- sysroot_linux-aarch64 # [linux and aarch64] -- xorg-x11-server-common-cos7-aarch64 # [linux and aarch64] -- xorg-x11-server-xvfb-cos7-aarch64 # [linux and aarch64] -- sed # [unix] +- libspnav # [linux] +- kernel-headers_linux-64 # [linux and x86_64] +- libdrm-conda-x86_64 # [linux and x86_64] +- libselinux-conda-x86_64 # [linux and x86_64] +- libsepol-conda-x86_64 # [linux and x86_64] +- libx11-common-conda-x86_64 # [linux and x86_64] +- libx11-conda-x86_64 # [linux and x86_64] +- libxau-conda-x86_64 # [linux and x86_64] +- libxcb-conda-x86_64 # [linux and x86_64] +- libxdamage-conda-x86_64 # [linux and x86_64] +- libxext-conda-x86_64 # [linux and x86_64] +- libxfixes-conda-x86_64 # [linux and x86_64] +- libxi-conda-x86_64 # [linux and x86_64] +- libxi-devel-conda-x86_64 # [linux and x86_64] +- libxxf86vm-conda-x86_64 # [linux and x86_64] +- mesa-dri-drivers-conda-x86_64 # [linux and x86_64] +- mesa-libegl-conda-x86_64 # [linux and x86_64] +- mesa-libegl-devel-conda-x86_64 # [linux and x86_64] +- mesa-libgl-conda-x86_64 # [linux and x86_64] +- mesa-libgl-devel-conda-x86_64 # [linux and x86_64] +- pixman-conda-x86_64 # [linux and x86_64] +- sysroot_linux-64 # [linux and x86_64] +- xorg-x11-server-common-conda-x86_64 # [linux and x86_64] +- xorg-x11-server-xvfb-conda-x86_64 # [linux and x86_64] +- kernel-headers_linux-aarch64 # [linux and aarch64] +- libdrm-conda-aarch64 # [linux and aarch64] +- libglvnd-conda-aarch64 # [linux and aarch64] +- libglvnd-glx-conda-aarch64 # [linux and aarch64] +- libselinux-conda-aarch64 # [linux and aarch64] +- libsepol-conda-aarch64 # [linux and aarch64] +- libx11-common-conda-aarch64 # [linux and aarch64] +- libx11-conda-aarch64 # [linux and aarch64] +- libxau-conda-aarch64 # [linux and aarch64] +- libxcb-conda-aarch64 # [linux and aarch64] +- libxdamage-conda-aarch64 # [linux and aarch64] +- libxext-conda-aarch64 # [linux and aarch64] +- libxfixes-conda-aarch64 # [linux and aarch64] +- libxi-conda-aarch64 # [linux and aarch64] +- libxi-devel-conda-aarch64 # [linux and aarch64] +- libxxf86vm-conda-aarch64 # [linux and aarch64] +- mesa-dri-drivers-conda-aarch64 # [linux and aarch64] +- mesa-khr-devel-conda-aarch64 # [linux and aarch64] +- mesa-libegl-conda-aarch64 # [linux and aarch64] +- mesa-libegl-devel-conda-aarch64 # [linux and aarch64] +- mesa-libgbm-conda-aarch64 # [linux and aarch64] +- mesa-libgl-conda-aarch64 # [linux and aarch64] +- mesa-libgl-devel-conda-aarch64 # [linux and aarch64] +- mesa-libglapi-conda-aarch64 # [linux and aarch64] +- pixman-conda-aarch64 # [linux and aarch64] +- sysroot_linux-aarch64 # [linux and aarch64] +- xorg-x11-server-common-conda-aarch64 # [linux and aarch64] +- xorg-x11-server-xvfb-conda-aarch64 # [linux and aarch64] +- sed # [unix] - ccache - cmake - coin3d - compilers +- gcc==13.3.* # [linux] +- gxx==13.3.* # [linux] +- clang==18.1.* # [osx] +- clangxx==18.1.* # [osx] - conda - conda-devenv - debugpy diff --git a/package/fedora/freecad.spec b/package/fedora/freecad.spec index 5c9366a90e73..762b8034e4f4 100644 --- a/package/fedora/freecad.spec +++ b/package/fedora/freecad.spec @@ -33,7 +33,7 @@ Name: %{name} Epoch: 1 -Version: 1.0.1 +Version: 1.0.2 Release: {{{git_commit_no}}}%{?dist} Summary: A general purpose 3D CAD modeler Group: Applications/Engineering @@ -97,7 +97,7 @@ BuildRequires: openmpi-devel BuildRequires: med-devel BuildRequires: libkdtree++-devel -%if ! %{pcl_enabled} +%if %{pcl_enabled} BuildRequires: pcl-devel %endif BuildRequires: python3 @@ -217,7 +217,7 @@ LDFLAGS='-Wl,--as-needed -Wl,--no-undefined'; export LDFLAGS -DCOIN3D_INCLUDE_DIR=%{_includedir}/Coin4 \ -DCOIN3D_DOC_PATH=%{_datadir}/Coin4/Coin \ -DUSE_OCC=TRUE \ -%if ! %{pcl_enabled} +%if %{pcl_enabled} -DFREECAD_USE_PCL:BOOL=ON \ %else -DFREECAD_USE_PCL:BOOL=OFF \ diff --git a/src/3rdParty/salomesmesh/inc/SMDS_UnstructuredGrid.hxx b/src/3rdParty/salomesmesh/inc/SMDS_UnstructuredGrid.hxx index 77465814541e..f02337cf52af 100644 --- a/src/3rdParty/salomesmesh/inc/SMDS_UnstructuredGrid.hxx +++ b/src/3rdParty/salomesmesh/inc/SMDS_UnstructuredGrid.hxx @@ -96,7 +96,11 @@ public: vtkCellLinks* GetLinks() { #ifdef VTK_CELL_ARRAY_V2 + #if VTK_VERSION_NUMBER_QUICK >= 90300000000 + return static_cast(vtkUnstructuredGrid::GetLinks()); + #else return static_cast(GetCellLinks()); + #endif #else return Links; #endif diff --git a/src/3rdParty/salomesmesh/src/SMDS/SMDS_Mesh.cpp b/src/3rdParty/salomesmesh/src/SMDS/SMDS_Mesh.cpp index a987e05058f0..baa6eadc9319 100644 --- a/src/3rdParty/salomesmesh/src/SMDS/SMDS_Mesh.cpp +++ b/src/3rdParty/salomesmesh/src/SMDS/SMDS_Mesh.cpp @@ -4713,7 +4713,11 @@ void SMDS_Mesh::dumpGrid(string ficdump) } ficcon << "-------------------------------- connectivity " << nbPoints << endl; #ifdef VTK_CELL_ARRAY_V2 + #if VTK_VERSION_NUMBER_QUICK >= 90300000000 + vtkCellLinks *links = static_cast(myGrid->GetLinks()); + #else vtkCellLinks *links = static_cast(myGrid->GetCellLinks()); + #endif #else vtkCellLinks *links = myGrid->GetCellLinks(); #endif diff --git a/src/3rdParty/salomesmesh/src/SMDS/SMDS_MeshNode.cpp b/src/3rdParty/salomesmesh/src/SMDS/SMDS_MeshNode.cpp index 7b8e7ae763e5..f5fc373f5dff 100644 --- a/src/3rdParty/salomesmesh/src/SMDS/SMDS_MeshNode.cpp +++ b/src/3rdParty/salomesmesh/src/SMDS/SMDS_MeshNode.cpp @@ -69,7 +69,11 @@ void SMDS_MeshNode::init(int id, int meshId, int shapeId, double x, double y, do SMDS_UnstructuredGrid * grid = mesh->getGrid(); vtkPoints *points = grid->GetPoints(); points->InsertPoint(myVtkID, x, y, z); +#if VTK_VERSION_NUMBER_QUICK >= 90300000000 + SMDS_CellLinks *cellLinks = dynamic_cast(grid->GetLinks()); +#else SMDS_CellLinks *cellLinks = dynamic_cast(grid->GetCellLinks()); +#endif assert(cellLinks); cellLinks->ResizeForPoint( myVtkID ); } @@ -191,7 +195,11 @@ class SMDS_MeshNode_MyInvIterator: public SMDS_ElemIterator SMDS_ElemIteratorPtr SMDS_MeshNode:: GetInverseElementIterator(SMDSAbs_ElementType type) const { +#if VTK_VERSION_NUMBER_QUICK >= 90300000000 + vtkCellLinks::Link l = static_cast(SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetLinks())->GetLink(myVtkID); +#else vtkCellLinks::Link l = static_cast(SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks())->GetLink(myVtkID); +#endif //MESSAGE("myID " << myID << " ncells " << l.ncells); return SMDS_ElemIteratorPtr(new SMDS_MeshNode_MyInvIterator(SMDS_Mesh::_meshList[myMeshId], l.cells, l.ncells, type)); } @@ -251,7 +259,11 @@ elementsIterator(SMDSAbs_ElementType type) const return SMDS_MeshElement::elementsIterator(SMDSAbs_Node); else { +#if VTK_VERSION_NUMBER_QUICK >= 90300000000 + vtkCellLinks::Link l = static_cast(SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetLinks())->GetLink(myVtkID); +#else vtkCellLinks::Link l = static_cast(SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks())->GetLink(myVtkID); +#endif return SMDS_ElemIteratorPtr(new SMDS_MeshNode_MyIterator(SMDS_Mesh::_meshList[myMeshId], l.cells, l.ncells, type)); } } @@ -350,7 +362,11 @@ void SMDS_MeshNode::AddInverseElement(const SMDS_MeshElement* ME) const SMDS_MeshCell *cell = dynamic_cast (ME); assert(cell); SMDS_UnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid(); +#if VTK_VERSION_NUMBER_QUICK >= 90300000000 + vtkCellLinks *Links = static_cast(grid->GetLinks()); +#else vtkCellLinks *Links = static_cast(grid->GetCellLinks()); +#endif Links->ResizeCellList(myVtkID, 1); Links->AddCellReference(cell->getVtkId(), myVtkID); } @@ -366,7 +382,11 @@ void SMDS_MeshNode::ClearInverseElements() bool SMDS_MeshNode::emptyInverseElements() { +#if VTK_VERSION_NUMBER_QUICK >= 90300000000 + vtkCellLinks::Link l = static_cast(SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetLinks())->GetLink(myVtkID); +#else vtkCellLinks::Link l = static_cast(SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks())->GetLink(myVtkID); +#endif return (l.ncells == 0); } @@ -378,7 +398,11 @@ bool SMDS_MeshNode::emptyInverseElements() int SMDS_MeshNode::NbInverseElements(SMDSAbs_ElementType type) const { +#if VTK_VERSION_NUMBER_QUICK >= 90300000000 + vtkCellLinks::Link l = static_cast(SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetLinks())->GetLink(myVtkID); +#else vtkCellLinks::Link l = static_cast(SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks())->GetLink(myVtkID); +#endif if ( type == SMDSAbs_All ) return l.ncells; diff --git a/src/3rdParty/salomesmesh/src/SMESH/SMESH_MeshEditor.cpp b/src/3rdParty/salomesmesh/src/SMESH/SMESH_MeshEditor.cpp index a037b33af8f3..49b5f99cd6a2 100644 --- a/src/3rdParty/salomesmesh/src/SMESH/SMESH_MeshEditor.cpp +++ b/src/3rdParty/salomesmesh/src/SMESH/SMESH_MeshEditor.cpp @@ -11348,7 +11348,11 @@ bool SMESH_MeshEditor::DoubleNodesOnGroupBoundaries( const std::vector= 90300000000 + vtkCellLinks::Link l = static_cast(grid->GetLinks())->GetLink(oldId); +#else vtkCellLinks::Link l = static_cast(grid->GetCellLinks())->GetLink(oldId); +#endif for (int i=0; ifirst; //MESSAGE(" node " << oldId); +#if VTK_VERSION_NUMBER_QUICK >= 90300000000 + vtkCellLinks::Link l = static_cast(grid->GetLinks())->GetLink(oldId); +#else vtkCellLinks::Link l = static_cast(grid->GetCellLinks())->GetLink(oldId); +#endif for (int i = 0; i < l.ncells; i++) { int vtkId = l.cells[i]; diff --git a/src/App/ApplicationPy.cpp b/src/App/ApplicationPy.cpp index cfa9621103aa..99c619c0c4f0 100644 --- a/src/App/ApplicationPy.cpp +++ b/src/App/ApplicationPy.cpp @@ -851,7 +851,7 @@ PyObject *Application::sCheckLinkDepth(PyObject * /*self*/, PyObject *args) return nullptr; PY_TRY { - return Py::new_reference_to(Py::Int(GetApplication().checkLinkDepth(depth, MessageOption::Throw))); + return Py::new_reference_to(Py::Long(GetApplication().checkLinkDepth(depth, MessageOption::Throw))); }PY_CATCH; } @@ -926,7 +926,7 @@ PyObject *Application::sSetActiveTransaction(PyObject * /*self*/, PyObject *args return nullptr; PY_TRY { - Py::Int ret(GetApplication().setActiveTransaction(name, Base::asBoolean(persist))); + Py::Long ret(GetApplication().setActiveTransaction(name, Base::asBoolean(persist))); return Py::new_reference_to(ret); }PY_CATCH; } @@ -943,7 +943,7 @@ PyObject *Application::sGetActiveTransaction(PyObject * /*self*/, PyObject *args Py_Return; Py::Tuple ret(2); ret.setItem(0,Py::String(name)); - ret.setItem(1,Py::Int(id)); + ret.setItem(1,Py::Long(id)); return Py::new_reference_to(ret); }PY_CATCH; } diff --git a/src/App/ComplexGeoDataPy.xml b/src/App/ComplexGeoDataPy.xml index 7b094cb3dd1a..00fb61f10bad 100644 --- a/src/App/ComplexGeoDataPy.xml +++ b/src/App/ComplexGeoDataPy.xml @@ -117,7 +117,7 @@ Geometry Tag - + @@ -129,7 +129,7 @@ Get the current element map size - + diff --git a/src/App/ComplexGeoDataPyImp.cpp b/src/App/ComplexGeoDataPyImp.cpp index 1dc12cccddd7..3ebe9ee91992 100644 --- a/src/App/ComplexGeoDataPyImp.cpp +++ b/src/App/ComplexGeoDataPyImp.cpp @@ -106,9 +106,9 @@ PyObject* ComplexGeoDataPy::getFacesFromSubElement(PyObject *args) Py::List facet; for (const auto & it : facets) { Py::Tuple f(3); - f.setItem(0,Py::Int(int(it.I1))); - f.setItem(1,Py::Int(int(it.I2))); - f.setItem(2,Py::Int(int(it.I3))); + f.setItem(0,Py::Long(int(it.I1))); + f.setItem(1,Py::Long(int(it.I2))); + f.setItem(2,Py::Long(int(it.I3))); facet.append(f); } tuple.setItem(1, facet); @@ -141,8 +141,8 @@ PyObject* ComplexGeoDataPy::getLinesFromSubElement(PyObject *args) Py::List line; for (const auto & it : lines) { Py::Tuple l(2); - l.setItem(0,Py::Int((int)it.I1)); - l.setItem(1,Py::Int((int)it.I2)); + l.setItem(0,Py::Long((int)it.I1)); + l.setItem(1,Py::Long((int)it.I2)); line.append(l); } tuple.setItem(1, line); @@ -204,8 +204,8 @@ PyObject* ComplexGeoDataPy::getLines(PyObject *args) Py::List line; for (const auto & it : lines) { Py::Tuple l(2); - l.setItem(0,Py::Int((int)it.I1)); - l.setItem(1,Py::Int((int)it.I2)); + l.setItem(0,Py::Long((int)it.I1)); + l.setItem(1,Py::Long((int)it.I2)); line.append(l); } tuple.setItem(1, line); @@ -236,9 +236,9 @@ PyObject* ComplexGeoDataPy::getFaces(PyObject *args) Py::List facet; for (const auto & it : facets) { Py::Tuple f(3); - f.setItem(0,Py::Int((int)it.I1)); - f.setItem(1,Py::Int((int)it.I2)); - f.setItem(2,Py::Int((int)it.I3)); + f.setItem(0,Py::Long((int)it.I1)); + f.setItem(1,Py::Long((int)it.I2)); + f.setItem(2,Py::Long((int)it.I3)); facet.append(f); } tuple.setItem(1, facet); @@ -494,9 +494,9 @@ Py::Dict ComplexGeoDataPy::getElementReverseMap() const return ret; } -Py::Int ComplexGeoDataPy::getElementMapSize() const +Py::Long ComplexGeoDataPy::getElementMapSize() const { - return Py::Int((long)getComplexGeoDataPtr()->getElementMapSize()); + return Py::Long((long)getComplexGeoDataPtr()->getElementMapSize()); } void ComplexGeoDataPy::setHasher(Py::Object obj) @@ -559,12 +559,12 @@ Py::String ComplexGeoDataPy::getElementMapVersion() const } -Py::Int ComplexGeoDataPy::getTag() const +Py::Long ComplexGeoDataPy::getTag() const { - return Py::Int(getComplexGeoDataPtr()->Tag); + return Py::Long(getComplexGeoDataPtr()->Tag); } -void ComplexGeoDataPy::setTag(Py::Int tag) +void ComplexGeoDataPy::setTag(Py::Long tag) { getComplexGeoDataPtr()->Tag = tag; } diff --git a/src/App/DocumentObjectPy.xml b/src/App/DocumentObjectPy.xml index 463c013edf82..f17ae7913cbb 100644 --- a/src/App/DocumentObjectPy.xml +++ b/src/App/DocumentObjectPy.xml @@ -305,7 +305,7 @@ or None if the GUI is not up The unique identifier (among its document) of this object - + diff --git a/src/App/DocumentObjectPyImp.cpp b/src/App/DocumentObjectPyImp.cpp index af09d7d9982a..b99217cc1b89 100644 --- a/src/App/DocumentObjectPyImp.cpp +++ b/src/App/DocumentObjectPyImp.cpp @@ -776,8 +776,8 @@ int DocumentObjectPy::setCustomAttributes(const char* , PyObject *) return 0; } -Py::Int DocumentObjectPy::getID() const { - return Py::Int(getDocumentObjectPtr()->getID()); +Py::Long DocumentObjectPy::getID() const { + return Py::Long(getDocumentObjectPtr()->getID()); } Py::Boolean DocumentObjectPy::getRemoving() const { diff --git a/src/App/DocumentPy.xml b/src/App/DocumentPy.xml index c43726622c44..9c69b0ce815b 100644 --- a/src/App/DocumentPy.xml +++ b/src/App/DocumentPy.xml @@ -301,25 +301,25 @@ sort: whether to topologically sort the return list The Undo mode of the Document (0 = no Undo, 1 = Undo/Redo) - + The size of the Undo stack in byte - + Number of possible Undos - + Number of possible Redos - + diff --git a/src/App/DocumentPyImp.cpp b/src/App/DocumentPyImp.cpp index c9beed7a997e..141546acfc21 100644 --- a/src/App/DocumentPyImp.cpp +++ b/src/App/DocumentPyImp.cpp @@ -319,7 +319,7 @@ PyObject* DocumentPy::addObject(PyObject *args, PyObject *kwd) if (view) pyvp = Py::Object(view); if (pyvp.isNone()) - pyvp = Py::Int(1); + pyvp = Py::Long(1); // 'pyvp' is the python class with the implementation for ViewProvider if (pyvp.hasAttr("__vobject__")) { pyvp.setAttr("__vobject__", pyftr.getAttr("ViewObject")); @@ -583,7 +583,7 @@ PyObject* DocumentPy::recompute(PyObject * args) return nullptr; } - return Py::new_reference_to(Py::Int(objectCount)); + return Py::new_reference_to(Py::Long(objectCount)); } PY_CATCH; } @@ -758,30 +758,30 @@ Py::List DocumentPy::getRootObjectsIgnoreLinks() const return res; } -Py::Int DocumentPy::getUndoMode() const +Py::Long DocumentPy::getUndoMode() const { - return Py::Int(getDocumentPtr()->getUndoMode()); + return Py::Long(getDocumentPtr()->getUndoMode()); } -void DocumentPy::setUndoMode(Py::Int arg) +void DocumentPy::setUndoMode(Py::Long arg) { getDocumentPtr()->setUndoMode(arg); } -Py::Int DocumentPy::getUndoRedoMemSize() const +Py::Long DocumentPy::getUndoRedoMemSize() const { - return Py::Int((long)getDocumentPtr()->getUndoMemSize()); + return Py::Long((long)getDocumentPtr()->getUndoMemSize()); } -Py::Int DocumentPy::getUndoCount() const +Py::Long DocumentPy::getUndoCount() const { - return Py::Int((long)getDocumentPtr()->getAvailableUndos()); + return Py::Long((long)getDocumentPtr()->getAvailableUndos()); } -Py::Int DocumentPy::getRedoCount() const +Py::Long DocumentPy::getRedoCount() const { - return Py::Int((long)getDocumentPtr()->getAvailableRedos()); + return Py::Long((long)getDocumentPtr()->getAvailableRedos()); } Py::List DocumentPy::getUndoNames() const diff --git a/src/App/FeaturePython.cpp b/src/App/FeaturePython.cpp index fa9c7018e957..70e79b48e95f 100644 --- a/src/App/FeaturePython.cpp +++ b/src/App/FeaturePython.cpp @@ -264,12 +264,12 @@ bool FeaturePythonImp::getSubObject(DocumentObject *&ret, const char *subname, args.setItem(0, Py::Object(object->getPyObject(), true)); if(!subname) subname = ""; args.setItem(1,Py::String(subname)); - args.setItem(2,Py::Int(pyObj?2:1)); + args.setItem(2,Py::Long(pyObj?2:1)); Base::MatrixPy *pyMat = new Base::MatrixPy(new Base::Matrix4D); if(_mat) *pyMat->getMatrixPtr() = *_mat; args.setItem(3,Py::asObject(pyMat)); args.setItem(4,Py::Boolean(transform)); - args.setItem(5,Py::Int(depth)); + args.setItem(5,Py::Long(depth)); Py::Object res(Base::pyCall(py_getSubObject.ptr(),args.ptr())); if(res.isNone()) { @@ -320,7 +320,7 @@ bool FeaturePythonImp::getSubObjects(std::vector &ret, int reason) try { Py::Tuple args(2); args.setItem(0, Py::Object(object->getPyObject(), true)); - args.setItem(1, Py::Int(reason)); + args.setItem(1, Py::Long(reason)); Py::Object res(Base::pyCall(py_getSubObjects.ptr(),args.ptr())); if(!res.isTrue()) return true; @@ -359,7 +359,7 @@ bool FeaturePythonImp::getLinkedObject(DocumentObject *&ret, bool recurse, if(_mat) *pyMat->getMatrixPtr() = *_mat; args.setItem(2,Py::asObject(pyMat)); args.setItem(3,Py::Boolean(transform)); - args.setItem(4,Py::Int(depth)); + args.setItem(4,Py::Long(depth)); Py::Object res(Base::pyCall(py_getLinkedObject.ptr(),args.ptr())); if(!res.isTrue()) { @@ -432,7 +432,7 @@ int FeaturePythonImp::isElementVisible(const char *element) const { Py::Tuple args(2); args.setItem(0, Py::Object(object->getPyObject(), true)); args.setItem(1,Py::String(element?element:"")); - return Py::Int(Base::pyCall(py_isElementVisible.ptr(),args.ptr())); + return Py::Long(Base::pyCall(py_isElementVisible.ptr(),args.ptr())); } catch (Py::Exception&) { if (PyErr_ExceptionMatches(PyExc_NotImplementedError)) { @@ -453,7 +453,7 @@ int FeaturePythonImp::setElementVisible(const char *element, bool visible) { args.setItem(0, Py::Object(object->getPyObject(), true)); args.setItem(1,Py::String(element?element:"")); args.setItem(2,Py::Boolean(visible)); - return Py::Int(Base::pyCall(py_setElementVisible.ptr(),args.ptr())); + return Py::Long(Base::pyCall(py_setElementVisible.ptr(),args.ptr())); } catch (Py::Exception&) { if (PyErr_ExceptionMatches(PyExc_NotImplementedError)) { @@ -534,7 +534,7 @@ int FeaturePythonImp::canLoadPartial() const { try { Py::Tuple args(1); args.setItem(0, Py::Object(object->getPyObject(), true)); - Py::Int ret(Base::pyCall(py_canLoadPartial.ptr(),args.ptr())); + Py::Long ret(Base::pyCall(py_canLoadPartial.ptr(),args.ptr())); return ret; } catch (Py::Exception&) { diff --git a/src/App/Link.cpp b/src/App/Link.cpp index 815787de66fa..d3215b1b2021 100644 --- a/src/App/Link.cpp +++ b/src/App/Link.cpp @@ -364,7 +364,7 @@ App::DocumentObjectExecReturn *LinkBaseExtension::extensionExecute() { } else { const auto &elements = _getElementListValue(); for(int i=0; i<_getElementCountValue(); ++i) { - args.setItem(2, Py::Int(i)); + args.setItem(2, Py::Long(i)); if(i < (int)elements.size()) args.setItem(3, Py::asObject(elements[i]->getPyObject())); else diff --git a/src/App/LinkBaseExtensionPyImp.cpp b/src/App/LinkBaseExtensionPyImp.cpp index 10819f290103..d068bbc2d62d 100644 --- a/src/App/LinkBaseExtensionPyImp.cpp +++ b/src/App/LinkBaseExtensionPyImp.cpp @@ -238,7 +238,7 @@ PyObject* LinkBaseExtensionPy::setLink(PyObject *_args) PyObject *key, *value; Py_ssize_t pos = 0; while(PyDict_Next(pcObj, &pos, &key, &value)) - parseLink(ext,Py::Int(key),value); + parseLink(ext,Py::Long(key),value); }else if(PySequence_Check(pcObj)) { ext->setLink(-1,nullptr); Py::Sequence seq(pcObj); diff --git a/src/App/ObjectIdentifier.cpp b/src/App/ObjectIdentifier.cpp index a8294d3d9aa0..f86c91117e57 100644 --- a/src/App/ObjectIdentifier.cpp +++ b/src/App/ObjectIdentifier.cpp @@ -626,16 +626,16 @@ Py::Object ObjectIdentifier::Component::get(const Py::Object &pyobj) const { res = pyobj.getAttr(getName()); } else if(isArray()) { if(pyobj.isMapping()) - res = Py::Mapping(pyobj).getItem(Py::Int(begin)); + res = Py::Mapping(pyobj).getItem(Py::Long(begin)); else res = Py::Sequence(pyobj).getItem(begin); }else if(isMap()) res = Py::Mapping(pyobj).getItem(getName()); else { assert(isRange()); - Py::Object slice(PySlice_New(Py::Int(begin).ptr(), - end!=INT_MAX?Py::Int(end).ptr():nullptr, - step!=1?Py::Int(step).ptr():nullptr),true); + Py::Object slice(PySlice_New(Py::Long(begin).ptr(), + end!=INT_MAX?Py::Long(end).ptr():nullptr, + step!=1?Py::Long(step).ptr():nullptr),true); PyObject *r = PyObject_GetItem(pyobj.ptr(),slice.ptr()); if(!r) Base::PyException::ThrowException(); @@ -654,16 +654,16 @@ void ObjectIdentifier::Component::set(Py::Object &pyobj, const Py::Object &value Base::PyException::ThrowException(); } else if(isArray()) { if(pyobj.isMapping()) - Py::Mapping(pyobj).setItem(Py::Int(begin),value); + Py::Mapping(pyobj).setItem(Py::Long(begin),value); else Py::Sequence(pyobj).setItem(begin,value); }else if(isMap()) Py::Mapping(pyobj).setItem(getName(),value); else { assert(isRange()); - Py::Object slice(PySlice_New(Py::Int(begin).ptr(), - end!=INT_MAX?Py::Int(end).ptr():nullptr, - step!=1?Py::Int(step).ptr():nullptr),true); + Py::Object slice(PySlice_New(Py::Long(begin).ptr(), + end!=INT_MAX?Py::Long(end).ptr():nullptr, + step!=1?Py::Long(step).ptr():nullptr),true); if(PyObject_SetItem(pyobj.ptr(),slice.ptr(),value.ptr())<0) Base::PyException::ThrowException(); } @@ -674,16 +674,16 @@ void ObjectIdentifier::Component::del(Py::Object &pyobj) const { pyobj.delAttr(getName()); else if(isArray()) { if(pyobj.isMapping()) - Py::Mapping(pyobj).delItem(Py::Int(begin)); + Py::Mapping(pyobj).delItem(Py::Long(begin)); else PySequence_DelItem(pyobj.ptr(),begin); } else if(isMap()) Py::Mapping(pyobj).delItem(getName()); else { assert(isRange()); - Py::Object slice(PySlice_New(Py::Int(begin).ptr(), - end!=INT_MAX?Py::Int(end).ptr():nullptr, - step!=1?Py::Int(step).ptr():nullptr),true); + Py::Object slice(PySlice_New(Py::Long(begin).ptr(), + end!=INT_MAX?Py::Long(end).ptr():nullptr, + step!=1?Py::Long(step).ptr():nullptr),true); if(PyObject_DelItem(pyobj.ptr(),slice.ptr())<0) Base::PyException::ThrowException(); } diff --git a/src/App/PropertyContainerPyImp.cpp b/src/App/PropertyContainerPyImp.cpp index 8e2196dbbf55..6c37e134e004 100644 --- a/src/App/PropertyContainerPyImp.cpp +++ b/src/App/PropertyContainerPyImp.cpp @@ -267,7 +267,7 @@ PyObject* PropertyContainerPy::setPropertyStatus(PyObject *args) status.set(it->second, value); } else if (item.isNumeric()) { - int v = Py::Int(item); + int v = Py::Long(item); if (v < 0) { value = false; v = -v; @@ -323,7 +323,7 @@ PyObject* PropertyContainerPy::getPropertyStatus(PyObject *args) } } if (!found) - ret.append(Py::Int(static_cast(i))); + ret.append(Py::Long(static_cast(i))); } } return Py::new_reference_to(ret); diff --git a/src/App/PropertyStandard.cpp b/src/App/PropertyStandard.cpp index 9b3384b9384d..1005847de1d6 100644 --- a/src/App/PropertyStandard.cpp +++ b/src/App/PropertyStandard.cpp @@ -478,7 +478,7 @@ void PropertyEnumeration::setPyObject(PyObject *value) if(seq.size() == 2) { Py::Object v(seq[0].ptr()); if(!v.isString() && v.isSequence()) { - idx = Py::Int(seq[1].ptr()); + idx = Py::Long(seq[1].ptr()); seq = v; } } @@ -579,14 +579,14 @@ bool PropertyEnumeration::getPyPathValue(const ObjectIdentifier &path, Py::Objec else { Py::Tuple tuple(2); tuple.setItem(0, res); - tuple.setItem(1, Py::Int(getValue())); + tuple.setItem(1, Py::Long(getValue())); r = tuple; } } else if (p == ".String") { auto v = getValueAsString(); r = Py::String(v?v:""); } else - r = Py::Int(getValue()); + r = Py::Long(getValue()); return true; } diff --git a/src/App/StringHasherPy.xml b/src/App/StringHasherPy.xml index d7df2b0e256f..e8d1f52d5f83 100644 --- a/src/App/StringHasherPy.xml +++ b/src/App/StringHasherPy.xml @@ -40,13 +40,13 @@ base64: indicate if the input 'txt' is base64 encoded binary data Return count of used hashes - + Return the size of the hashes - + @@ -58,7 +58,7 @@ base64: indicate if the input 'txt' is base64 encoded binary data Data length exceed this threshold will be hashed before storing - + diff --git a/src/App/StringIDPy.xml b/src/App/StringIDPy.xml index eb43002f4007..f3f6d043014a 100644 --- a/src/App/StringIDPy.xml +++ b/src/App/StringIDPy.xml @@ -24,7 +24,7 @@ Return the integer value of this ID - + @@ -54,7 +54,7 @@ Geometry index. Only meaningful for geometry element name - + private: friend class StringID; diff --git a/src/Base/MatrixPyImp.cpp b/src/Base/MatrixPyImp.cpp index fbd21b4688ef..029f57af2ca3 100644 --- a/src/Base/MatrixPyImp.cpp +++ b/src/Base/MatrixPyImp.cpp @@ -212,7 +212,7 @@ PyObject* MatrixPy::number_power_handler(PyObject* self, PyObject* other, PyObje Base::Matrix4D a = static_cast(self)->value(); - long b = Py::Int(other); + long b = Py::Long(other); if (b == 0) { return new MatrixPy(Matrix4D()); } @@ -363,7 +363,7 @@ PyObject* MatrixPy::hasScale(PyObject* args) ScaleType type = getMatrixPtr()->hasScale(tol); Py::Module mod("FreeCAD"); return Py::new_reference_to( - mod.callMemberFunction("ScaleType", Py::TupleN(Py::Int(static_cast(type))))); + mod.callMemberFunction("ScaleType", Py::TupleN(Py::Long(static_cast(type))))); } PyObject* MatrixPy::decompose(PyObject* args) diff --git a/src/Base/PersistencePy.xml b/src/Base/PersistencePy.xml index 4638e43e01f8..d8ffbd55cfa8 100644 --- a/src/Base/PersistencePy.xml +++ b/src/Base/PersistencePy.xml @@ -26,7 +26,7 @@ Class to dump and restore the content of an object. Memory size of the object in bytes. - + diff --git a/src/Base/PersistencePyImp.cpp b/src/Base/PersistencePyImp.cpp index 3c9f72d3232b..7e98b2563120 100644 --- a/src/Base/PersistencePyImp.cpp +++ b/src/Base/PersistencePyImp.cpp @@ -52,9 +52,9 @@ Py::String PersistencePy::getContent() const return {writer.getString()}; } -Py::Int PersistencePy::getMemSize() const +Py::Long PersistencePy::getMemSize() const { - return Py::Int((long)getPersistencePtr()->getMemSize()); + return Py::Long((long)getPersistencePtr()->getMemSize()); } PyObject* PersistencePy::dumpContent(PyObject* args, PyObject* kwds) diff --git a/src/Base/QuantityPyImp.cpp b/src/Base/QuantityPyImp.cpp index 4a59496f42b9..995ee2dfaa8e 100644 --- a/src/Base/QuantityPyImp.cpp +++ b/src/Base/QuantityPyImp.cpp @@ -641,9 +641,9 @@ Py::Dict QuantityPy::getFormat() const QuantityFormat fmt = getQuantityPtr()->getFormat(); Py::Dict dict; - dict.setItem("Precision", Py::Int(fmt.precision)); + dict.setItem("Precision", Py::Long(fmt.precision)); dict.setItem("NumberFormat", Py::Char(fmt.toFormat())); - dict.setItem("Denominator", Py::Int(fmt.denominator)); + dict.setItem("Denominator", Py::Long(fmt.denominator)); return dict; } @@ -652,14 +652,14 @@ void QuantityPy::setFormat(Py::Dict arg) QuantityFormat fmt = getQuantityPtr()->getFormat(); if (arg.hasKey("Precision")) { - Py::Int prec(arg.getItem("Precision")); + Py::Long prec(arg.getItem("Precision")); fmt.precision = static_cast(prec); } if (arg.hasKey("NumberFormat")) { Py::Object item = arg.getItem("NumberFormat"); if (item.isNumeric()) { - int format = static_cast(Py::Int(item)); + int format = static_cast(Py::Long(item)); if (format < 0 || format > QuantityFormat::Scientific) { throw Py::ValueError("Invalid format value"); } @@ -681,7 +681,7 @@ void QuantityPy::setFormat(Py::Dict arg) } if (arg.hasKey("Denominator")) { - Py::Int denom(arg.getItem("Denominator")); + Py::Long denom(arg.getItem("Denominator")); int fracInch = static_cast(denom); // check that the value is positive and a power of 2 if (fracInch <= 0) { diff --git a/src/Gui/Command.cpp b/src/Gui/Command.cpp index 750cd4fbf0cb..f528fba9c5e8 100644 --- a/src/Gui/Command.cpp +++ b/src/Gui/Command.cpp @@ -1560,7 +1560,7 @@ void PythonGroupCommand::activated(int iMsg) if (cmd.hasAttr("Activated")) { Py::Callable call(cmd.getAttr("Activated")); Py::Tuple args(1); - args.setItem(0, Py::Int(iMsg)); + args.setItem(0, Py::Long(iMsg)); Py::Object ret = call.apply(args); } // If the command group doesn't implement the 'Activated' method then invoke the command directly @@ -1640,7 +1640,7 @@ Action * PythonGroupCommand::createAction() if (cmd.hasAttr("GetDefaultCommand")) { Py::Callable call2(cmd.getAttr("GetDefaultCommand")); - Py::Int def(call2.apply(args)); + Py::Long def(call2.apply(args)); defaultId = static_cast(def); } diff --git a/src/Gui/DocumentPy.xml b/src/Gui/DocumentPy.xml index d3fdeada96fe..5a3dd85ebc9e 100644 --- a/src/Gui/DocumentPy.xml +++ b/src/Gui/DocumentPy.xml @@ -223,7 +223,7 @@ obj : Gui.ViewProvider Current edit mode. Only meaningful when there is a current object in edit. - + diff --git a/src/Gui/DocumentPyImp.cpp b/src/Gui/DocumentPyImp.cpp index c53832fdf1ff..9f387c102283 100644 --- a/src/Gui/DocumentPyImp.cpp +++ b/src/Gui/DocumentPyImp.cpp @@ -471,7 +471,7 @@ Py::Object DocumentPy::getInEditInfo() const { return Py::None(); return Py::TupleN(Py::Object(vp->getObject()->getPyObject(),true), - Py::String(subname),Py::String(subelement),Py::Int(mode)); + Py::String(subname),Py::String(subelement),Py::Long(mode)); } void DocumentPy::setInEditInfo(Py::Object arg) @@ -486,12 +486,12 @@ void DocumentPy::setInEditInfo(Py::Object arg) pyobj)->getViewProviderDocumentObjectPtr(),subname); } -Py::Int DocumentPy::getEditMode() const +Py::Long DocumentPy::getEditMode() const { int mode = -1; getDocumentPtr()->getInEdit(nullptr,nullptr,&mode); - return Py::Int(mode); + return Py::Long(mode); } Py::Boolean DocumentPy::getTransacting() const diff --git a/src/Gui/LinkViewPy.xml b/src/Gui/LinkViewPy.xml index 9341090f8526..cf00ba3eac9f 100644 --- a/src/Gui/LinkViewPy.xml +++ b/src/Gui/LinkViewPy.xml @@ -154,7 +154,7 @@ Return a tuple(path,detail) for the coin3D SoPath and SoDetail of the element Set the element size to create an array of linked object - + diff --git a/src/Gui/LinkViewPyImp.cpp b/src/Gui/LinkViewPyImp.cpp index c7cccdd198e7..efc738216fe7 100644 --- a/src/Gui/LinkViewPyImp.cpp +++ b/src/Gui/LinkViewPyImp.cpp @@ -83,7 +83,7 @@ PyObject* LinkViewPy::setMaterial(PyObject *args) { Py_ssize_t pos = 0; std::map materials; while(PyDict_Next(pyObj, &pos, &key, &value)) { - Py::Int idx(key); + Py::Long idx(key); if(value == Py_None) materials[(int)idx] = nullptr; else if(!PyObject_TypeCheck(value,&App::MaterialPy::Type)) { @@ -135,7 +135,7 @@ PyObject* LinkViewPy::setTransform(PyObject *args) { Py_ssize_t pos = 0; std::map mat; while(PyDict_Next(pyObj, &pos, &key, &value)) { - Py::Int idx(key); + Py::Long idx(key); if(!PyObject_TypeCheck(value,&Base::MatrixPy::Type)) { PyErr_SetString(PyExc_TypeError, "exepcting a type of Matrix"); return nullptr; @@ -384,11 +384,11 @@ PyObject* LinkViewPy::getChildren(PyObject *args) { return Py::new_reference_to(ret); } -Py::Int LinkViewPy::getCount() const { - return Py::Int(getLinkViewPtr()->getSize()); +Py::Long LinkViewPy::getCount() const { + return Py::Long(getLinkViewPtr()->getSize()); } -void LinkViewPy::setCount(Py::Int count) { +void LinkViewPy::setCount(Py::Long count) { try { getLinkViewPtr()->setSize((int)count); } catch (const Base::Exception& e) { diff --git a/src/Gui/PythonConsolePy.cpp b/src/Gui/PythonConsolePy.cpp index 7d81406ef19f..08b1f415a664 100644 --- a/src/Gui/PythonConsolePy.cpp +++ b/src/Gui/PythonConsolePy.cpp @@ -50,7 +50,7 @@ Py::Object PythonStdout::getattr(const char *name) { if (strcmp(name, "softspace") == 0) { int i=0; - return Py::Int(i); + return Py::Long(i); } return getattr_methods(name); } @@ -114,7 +114,7 @@ Py::Object PythonStderr::getattr(const char *name) { if (strcmp(name, "softspace") == 0) { int i=0; - return Py::Int(i); + return Py::Long(i); } return getattr_methods(name); } @@ -175,7 +175,7 @@ Py::Object OutputStdout::getattr(const char *name) { if (strcmp(name, "softspace") == 0) { int i=0; - return Py::Int(i); + return Py::Long(i); } return getattr_methods(name); } @@ -236,7 +236,7 @@ Py::Object OutputStderr::getattr(const char *name) { if (strcmp(name, "softspace") == 0) { int i=0; - return Py::Int(i); + return Py::Long(i); } return getattr_methods(name); } diff --git a/src/Gui/PythonWrapper.cpp b/src/Gui/PythonWrapper.cpp index fa4d06a64b6e..efaa09d8c942 100644 --- a/src/Gui/PythonWrapper.cpp +++ b/src/Gui/PythonWrapper.cpp @@ -401,34 +401,39 @@ class WrapperManager : public QObject */ void addQObject(QObject* obj, PyObject* pyobj) { - const auto PyW_unique_name = QString::number(reinterpret_cast (pyobj)); - auto PyW_invalidator = findChild (PyW_unique_name, Qt::FindDirectChildrenOnly); + // static array to contain created connections so they can be safely disconnected later + static std::map connections = {}; + + const auto PyW_uniqueName = QString::number(reinterpret_cast(pyobj)); + auto PyW_invalidator = findChild(PyW_uniqueName, Qt::FindDirectChildrenOnly); if (PyW_invalidator == nullptr) { PyW_invalidator = new QObject(this); - PyW_invalidator->setObjectName(PyW_unique_name); + PyW_invalidator->setObjectName(PyW_uniqueName); Py_INCREF (pyobj); } - else { - PyW_invalidator->disconnect(); + else if (connections[PyW_invalidator]) { + disconnect(connections[PyW_invalidator]); + connections.erase(PyW_invalidator); } - auto destroyedFun = [pyobj](){ + auto destroyedFun = [pyobj]() { Base::PyGILStateLocker lock; - auto sbk_ptr = reinterpret_cast (pyobj); - if (sbk_ptr != nullptr) { - Shiboken::Object::setValidCpp(sbk_ptr, false); + + if (auto sbkPtr = reinterpret_cast(pyobj); sbkPtr != nullptr) { + Shiboken::Object::setValidCpp(sbkPtr, false); } else { Base::Console().DeveloperError("WrapperManager", "A QObject has just been destroyed after its Pythonic wrapper.\n"); } + Py_DECREF (pyobj); }; - QObject::connect(PyW_invalidator, &QObject::destroyed, this, destroyedFun); - QObject::connect(obj, &QObject::destroyed, PyW_invalidator, &QObject::deleteLater); -} + connections[PyW_invalidator] = connect(PyW_invalidator, &QObject::destroyed, this, destroyedFun); + connect(obj, &QObject::destroyed, PyW_invalidator, &QObject::deleteLater); + } private: void wrapQApplication() diff --git a/src/Gui/SoDatumLabel.cpp b/src/Gui/SoDatumLabel.cpp index b0fb49f666bd..4f4622b22145 100644 --- a/src/Gui/SoDatumLabel.cpp +++ b/src/Gui/SoDatumLabel.cpp @@ -78,6 +78,7 @@ SoDatumLabel::SoDatumLabel() SO_NODE_ADD_FIELD(name, ("Helvetica")); SO_NODE_ADD_FIELD(size, (10.F)); SO_NODE_ADD_FIELD(lineWidth, (2.F)); + SO_NODE_ADD_FIELD(sampling, (2.F)); SO_NODE_ADD_FIELD(datumtype, (SoDatumLabel::DISTANCE)); @@ -131,7 +132,8 @@ void SoDatumLabel::drawImage() QColor front; front.setRgbF(t[0],t[1], t[2]); - QImage image(w, h,QImage::Format_ARGB32_Premultiplied); + QImage image(w * sampling.getValue(), h * sampling.getValue(), QImage::Format_ARGB32_Premultiplied); + image.setDevicePixelRatio(sampling.getValue()); image.fill(0x00000000); QPainter painter(&image); @@ -1070,7 +1072,7 @@ void SoDatumLabel::getDimension(float scale, int& srcw, int& srch) srch = imgsize[1]; float aspectRatio = (float) srcw / (float) srch; - this->imgHeight = scale * (float) (srch); + this->imgHeight = scale * (float) (srch) / sampling.getValue(); this->imgWidth = aspectRatio * (float) this->imgHeight; } diff --git a/src/Gui/SoDatumLabel.h b/src/Gui/SoDatumLabel.h index 70aa8c8b96fb..70dcc7fa9003 100644 --- a/src/Gui/SoDatumLabel.h +++ b/src/Gui/SoDatumLabel.h @@ -85,6 +85,7 @@ class GuiExport SoDatumLabel : public SoShape { SoSFVec3f norm; SoSFImage image; SoSFFloat lineWidth; + SoSFFloat sampling; bool useAntialiasing; protected: diff --git a/src/Gui/View3DPy.cpp b/src/Gui/View3DPy.cpp index 3bd3da248d4c..6a0a8f731942 100644 --- a/src/Gui/View3DPy.cpp +++ b/src/Gui/View3DPy.cpp @@ -1274,8 +1274,8 @@ Py::Object View3DInventorPy::getCursorPos() auto viewer = getView3DIventorPtr()->getViewer(); SbVec2s vec = viewer->fromQPoint(pos); Py::Tuple tuple(2); - tuple.setItem(0, Py::Int(vec[0])); - tuple.setItem(1, Py::Int(vec[1])); + tuple.setItem(0, Py::Long(vec[0])); + tuple.setItem(1, Py::Long(vec[1])); return tuple; } catch (const Py::Exception&) { @@ -1292,13 +1292,13 @@ Py::Object View3DInventorPy::getObjectInfo(const Py::Tuple& args) try { //Note: For gcc (4.2) we need the 'const' keyword to avoid the compiler error: - //conversion from 'Py::seqref' to non-scalar type 'Py::Int' requested + //conversion from 'Py::seqref' to non-scalar type 'Py::Long' requested //We should report this problem to the PyCXX project as in the documentation an //example without the 'const' keyword is used. - //Or we can also write Py::Int x(tuple[0]); + //Or we can also write Py::Long x(tuple[0]); const Py::Tuple tuple(object); - Py::Int x(tuple[0]); - Py::Int y(tuple[1]); + Py::Long x(tuple[0]); + Py::Long y(tuple[1]); // As this method could be called during a SoHandleEventAction scene // graph traversal we must not use a second SoHandleEventAction as @@ -1398,13 +1398,13 @@ Py::Object View3DInventorPy::getObjectsInfo(const Py::Tuple& args) try { //Note: For gcc (4.2) we need the 'const' keyword to avoid the compiler error: - //conversion from 'Py::seqref' to non-scalar type 'Py::Int' requested + //conversion from 'Py::seqref' to non-scalar type 'Py::Long' requested //We should report this problem to the PyCXX project as in the documentation an //example without the 'const' keyword is used. - //Or we can also write Py::Int x(tuple[0]); + //Or we can also write Py::Long x(tuple[0]); const Py::Tuple tuple(object); - Py::Int x(tuple[0]); - Py::Int y(tuple[1]); + Py::Long x(tuple[0]); + Py::Long y(tuple[1]); // As this method could be called during a SoHandleEventAction scene // graph traversal we must not use a second SoHandleEventAction as @@ -1506,8 +1506,8 @@ Py::Object View3DInventorPy::getSize() try { SbVec2s size = getView3DIventorPtr()->getViewer()->getSoRenderManager()->getSize(); Py::Tuple tuple(2); - tuple.setItem(0, Py::Int(size[0])); - tuple.setItem(1, Py::Int(size[1])); + tuple.setItem(0, Py::Long(size[0])); + tuple.setItem(1, Py::Long(size[1])); return tuple; } catch (const Py::Exception&) { @@ -1521,8 +1521,8 @@ Py::Object View3DInventorPy::getPointOnFocalPlane(const Py::Tuple& args) if (!PyArg_ParseTuple(args.ptr(), "hh", &x, &y)) { PyErr_Clear(); Py::Tuple t(args[0]); - x = (int)Py::Int(t[0]); - y = (int)Py::Int(t[1]); + x = (int)Py::Long(t[0]); + y = (int)Py::Long(t[1]); } try { SbVec3f pt = getView3DIventorPtr()->getViewer()->getPointOnFocalPlane(SbVec2s(x,y)); @@ -1556,8 +1556,8 @@ Py::Object View3DInventorPy::getPointOnViewport(const Py::Tuple& args) try { SbVec2s pt = getView3DIventorPtr()->getViewer()->getPointOnViewport(SbVec3f(vx,vy,vz)); Py::Tuple tuple(2); - tuple.setItem(0, Py::Int(pt[0])); - tuple.setItem(1, Py::Int(pt[1])); + tuple.setItem(0, Py::Long(pt[0])); + tuple.setItem(1, Py::Long(pt[1])); return tuple; } @@ -1575,8 +1575,8 @@ Py::Object View3DInventorPy::projectPointToLine(const Py::Tuple& args) if (!PyArg_ParseTuple(args.ptr(), "hh", &x, &y)) { PyErr_Clear(); Py::Tuple t(args[0]); - x = (int)Py::Int(t[0]); - y = (int)Py::Int(t[1]); + x = (int)Py::Long(t[0]); + y = (int)Py::Long(t[1]); } try { SbVec3f pt1, pt2; @@ -1635,8 +1635,8 @@ void View3DInventorPy::eventCallback(void * ud, SoEventCallback * n) dict.setItem("Time", Py::String(std::string(e->getTime().formatDate("%Y-%m-%d %H:%M:%S").getString()))); SbVec2s p = n->getEvent()->getPosition(); Py::Tuple pos(2); - pos.setItem(0, Py::Int(p[0])); - pos.setItem(1, Py::Int(p[1])); + pos.setItem(0, Py::Long(p[0])); + pos.setItem(1, Py::Long(p[1])); // Position dict.setItem("Position", pos); // Shift, Ctrl, Alt down @@ -2509,7 +2509,7 @@ Py::Object View3DInventorPy::setCornerCrossSize(const Py::Tuple& args) Py::Object View3DInventorPy::getCornerCrossSize() { int size = getView3DIventorPtr()->getViewer()->getFeedbackSize(); - return Py::Int(size); + return Py::Long(size); } Py::Object View3DInventorPy::cast_to_base() diff --git a/src/Gui/View3DViewerPy.cpp b/src/Gui/View3DViewerPy.cpp index f8026a12362d..5770d26ec815 100644 --- a/src/Gui/View3DViewerPy.cpp +++ b/src/Gui/View3DViewerPy.cpp @@ -267,8 +267,8 @@ Py::Object View3DInventorViewerPy::seekToPoint(const Py::Tuple& args) _viewer->seekToPoint(hitpoint); } else { - Py::Int x(tuple[0]); - Py::Int y(tuple[1]); + Py::Long x(tuple[0]); + Py::Long y(tuple[1]); SbVec2s hitpoint ((long)x,(long)y); _viewer->seekToPoint(hitpoint); @@ -334,8 +334,8 @@ Py::Object View3DInventorViewerPy::getPointOnFocalPlane(const Py::Tuple& args) if (!PyArg_ParseTuple(args.ptr(), "hh", &x, &y)) { PyErr_Clear(); Py::Tuple t(args[0]); - x = (int)Py::Int(t[0]); - y = (int)Py::Int(t[1]); + x = (int)Py::Long(t[0]); + y = (int)Py::Long(t[1]); } try { SbVec3f pt = _viewer->getPointOnFocalPlane(SbVec2s(x,y)); diff --git a/src/Gui/ViewProviderFeaturePython.cpp b/src/Gui/ViewProviderFeaturePython.cpp index 6e8499791341..c13ef185bb3b 100644 --- a/src/Gui/ViewProviderFeaturePython.cpp +++ b/src/Gui/ViewProviderFeaturePython.cpp @@ -356,7 +356,7 @@ ViewProviderFeaturePythonImp::setEdit(int ModNum) try { if (has__object__) { Py::Tuple args(1); - args.setItem(0, Py::Int(ModNum)); + args.setItem(0, Py::Long(ModNum)); Py::Object ret(Base::pyCall(py_setEdit.ptr(),args.ptr())); if (ret.isNone()) return NotImplemented; @@ -367,7 +367,7 @@ ViewProviderFeaturePythonImp::setEdit(int ModNum) else { Py::Tuple args(2); args.setItem(0, Py::Object(object->getPyObject(), true)); - args.setItem(1, Py::Int(ModNum)); + args.setItem(1, Py::Long(ModNum)); Py::Object ret(Base::pyCall(py_setEdit.ptr(),args.ptr())); if (ret.isNone()) return NotImplemented; @@ -397,7 +397,7 @@ ViewProviderFeaturePythonImp::unsetEdit(int ModNum) try { if (has__object__) { Py::Tuple args(1); - args.setItem(0, Py::Int(ModNum)); + args.setItem(0, Py::Long(ModNum)); Py::Object ret(Base::pyCall(py_unsetEdit.ptr(),args.ptr())); if (ret.isNone()) return NotImplemented; @@ -408,7 +408,7 @@ ViewProviderFeaturePythonImp::unsetEdit(int ModNum) else { Py::Tuple args(2); args.setItem(0, Py::Object(object->getPyObject(), true)); - args.setItem(1, Py::Int(ModNum)); + args.setItem(1, Py::Long(ModNum)); Py::Object ret(Base::pyCall(py_unsetEdit.ptr(),args.ptr())); if (ret.isNone()) return NotImplemented; @@ -439,7 +439,7 @@ ViewProviderFeaturePythonImp::setEditViewer(View3DInventorViewer *viewer, int Mo Py::Tuple args(3); args.setItem(0, Py::Object(object->getPyObject(),true)); args.setItem(1, Py::Object(viewer->getPyObject(),true)); - args.setItem(2, Py::Int(ModNum)); + args.setItem(2, Py::Long(ModNum)); Py::Object ret(Base::pyCall(py_setEditViewer.ptr(),args.ptr())); return ret.isTrue()?Accepted:Rejected; } @@ -649,7 +649,7 @@ void ViewProviderFeaturePythonImp::finishRestoring() Py::Object vp = Proxy.getValue(); if (vp.isNone()) { object->show(); - Proxy.setValue(Py::Int(1)); + Proxy.setValue(Py::Long(1)); } else { _FC_PY_CALL_CHECK(finishRestoring,return); Base::pyCall(py_finishRestoring.ptr()); diff --git a/src/Gui/ViewProviderPy.xml b/src/Gui/ViewProviderPy.xml index 8ce41e4debf2..943e05cdb455 100644 --- a/src/Gui/ViewProviderPy.xml +++ b/src/Gui/ViewProviderPy.xml @@ -314,7 +314,7 @@ view: View3DInventorPy Get/Set the default display mode in turns of coin node index. - + diff --git a/src/Gui/ViewProviderPyImp.cpp b/src/Gui/ViewProviderPyImp.cpp index 0471b7d33db7..b351d4fde1ee 100644 --- a/src/Gui/ViewProviderPyImp.cpp +++ b/src/Gui/ViewProviderPyImp.cpp @@ -304,7 +304,7 @@ PyObject* ViewProviderPy::replaceObject(PyObject *args) int ret = getViewProviderPtr()->replaceObject( static_cast(oldObj)->getDocumentObjectPtr(), static_cast(newObj)->getDocumentObjectPtr()); - return Py::new_reference_to(Py::Int(ret)); + return Py::new_reference_to(Py::Long(ret)); } PY_CATCH; } @@ -456,7 +456,7 @@ PyObject* ViewProviderPy::partialRender(PyObject* args) } } - Py::Int ret(getViewProviderPtr()->partialRender(values, Base::asBoolean(clear))); + Py::Long ret(getViewProviderPtr()->partialRender(values, Base::asBoolean(clear))); return Py::new_reference_to(ret); } @@ -677,12 +677,12 @@ Py::Object ViewProviderPy::getIcon() const return wrap.fromQIcon(new QIcon(icon)); } -Py::Int ViewProviderPy::getDefaultMode() const +Py::Long ViewProviderPy::getDefaultMode() const { - return Py::Int((long)getViewProviderPtr()->getDefaultMode()); + return Py::Long((long)getViewProviderPtr()->getDefaultMode()); } -void ViewProviderPy::setDefaultMode(Py::Int arg) +void ViewProviderPy::setDefaultMode(Py::Long arg) { return getViewProviderPtr()->setDefaultMode(arg); } diff --git a/src/Gui/WidgetFactory.cpp b/src/Gui/WidgetFactory.cpp index 8b9821e06767..20c045075944 100644 --- a/src/Gui/WidgetFactory.cpp +++ b/src/Gui/WidgetFactory.cpp @@ -584,7 +584,7 @@ Py::Object PyResource::value(const Py::Tuple& args) item = Py::Long(static_cast(v.toUInt())); break; case QMetaType::Int: - item = Py::Int(v.toInt()); + item = Py::Long(v.toInt()); break; default: item = Py::String(""); diff --git a/src/Mod/AddonManager/addonmanager_utilities.py b/src/Mod/AddonManager/addonmanager_utilities.py index a1507823937f..4b446f63b1c3 100644 --- a/src/Mod/AddonManager/addonmanager_utilities.py +++ b/src/Mod/AddonManager/addonmanager_utilities.py @@ -585,7 +585,7 @@ def create_pip_call(args: List[str]) -> List[str]: call_args = ["pip", "--disable-pip-version-check"] call_args.extend(args) elif appimage: - python_exe = fci.DataPaths.home_dir + "bin/python" + python_exe = fci.DataPaths().home_dir + "bin/python" call_args = [python_exe, "-m", "pip", "--disable-pip-version-check"] call_args.extend(args) else: diff --git a/src/Mod/Assembly/App/AssemblyObject.cpp b/src/Mod/Assembly/App/AssemblyObject.cpp index 510b34e31fc9..cad1c61b6fa8 100644 --- a/src/Mod/Assembly/App/AssemblyObject.cpp +++ b/src/Mod/Assembly/App/AssemblyObject.cpp @@ -1273,7 +1273,7 @@ AssemblyObject::makeMbdJoint(App::DocumentObject* joint) JointType jointType = getJointType(joint); std::shared_ptr mbdJoint = makeMbdJointOfType(joint, jointType); - if (!mbdJoint) { + if (!mbdJoint || !isMbDJointValid(joint)) { return {}; } @@ -1581,6 +1581,28 @@ int AssemblyObject::slidingPartIndex(App::DocumentObject* joint) return slidingFound; } +bool AssemblyObject::isMbDJointValid(App::DocumentObject* joint) +{ + // When dragging a part, we are bundling fixed parts together. + // This may lead to a conflicting joint that is self referencing a MbD part. + // The solver crash when fed such a bad joint. So we make sure it does not happen. + App::DocumentObject* part1 = getMovingPartFromRef(joint, "Reference1"); + App::DocumentObject* part2 = getMovingPartFromRef(joint, "Reference2"); + if (!part1 || !part2) { + return false; + } + + // If this joint is self-referential it must be ignored. + if (getMbDPart(part1) == getMbDPart(part2)) { + Base::Console().Warning( + "Assembly: Ignoring joint (%s) because its parts are connected by a fixed " + "joint bundle. This joint is a conflicting or redundant constraint.\n", + joint->getFullLabel()); + return false; + } + return true; +} + AssemblyObject::MbDPartData AssemblyObject::getMbDData(App::DocumentObject* part) { auto it = objectPartMap.find(part); diff --git a/src/Mod/Assembly/App/AssemblyObject.h b/src/Mod/Assembly/App/AssemblyObject.h index a51968058ee1..cf7c5fa6254c 100644 --- a/src/Mod/Assembly/App/AssemblyObject.h +++ b/src/Mod/Assembly/App/AssemblyObject.h @@ -245,6 +245,8 @@ class AssemblyExport AssemblyObject: public App::Part std::vector getSubAssemblies(); void updateGroundedJointsPlacements(); + bool isMbDJointValid(App::DocumentObject* joint); + private: std::shared_ptr mbdAssembly; diff --git a/src/Mod/BIM/ArchAxis.py b/src/Mod/BIM/ArchAxis.py index 41af4185e42e..a74756b43053 100644 --- a/src/Mod/BIM/ArchAxis.py +++ b/src/Mod/BIM/ArchAxis.py @@ -95,28 +95,29 @@ def execute(self,obj): pl = obj.Placement geoms = [] dist = 0 - if obj.Distances and obj.Length.Value: - if len(obj.Distances) == len(obj.Angles): - for i in range(len(obj.Distances)): - if hasattr(obj.Length,"Value"): - l = obj.Length.Value - else: - l = obj.Length - dist += obj.Distances[i] - ang = math.radians(obj.Angles[i]) - p1 = Vector(dist,0,0) - p2 = Vector(dist+(l/math.cos(ang))*math.sin(ang),l,0) + distances = [0] + angles = [0] + if hasattr(obj, "Distances"): + distances = obj.Distances + if hasattr(obj, "Angles"): + angles = obj.Angles + if distances and obj.Length.Value: + if angles and len(distances) == len(angles): + for i in range(len(distances)): + dist += distances[i] + ang = math.radians(angles[i]) + ln = obj.Length.Value + ln = 100 * ln if abs(math.cos(ang)) < 0.01 else ln / math.cos(ang) + unitvec = Vector(math.sin(ang), math.cos(ang), 0) + p1 = Vector(dist, 0, 0) + p2 = p1 + unitvec * ln if hasattr(obj,"Limit") and obj.Limit.Value: - p3 = p2.sub(p1) - p3.normalize() - p3.multiply(-obj.Limit.Value) - p4 = p1.sub(p2) - p4.normalize() - p4.multiply(-obj.Limit.Value) - geoms.append(Part.LineSegment(p1,p1.add(p4)).toShape()) - geoms.append(Part.LineSegment(p2,p2.add(p3)).toShape()) + p3 = unitvec * obj.Limit.Value + p4 = unitvec * -obj.Limit.Value + geoms.append(Part.LineSegment(p1, p1 + p3).toShape()) + geoms.append(Part.LineSegment(p2, p2 + p4).toShape()) else: - geoms.append(Part.LineSegment(p1,p2).toShape()) + geoms.append(Part.LineSegment(p1, p2).toShape()) if geoms: sh = Part.Compound(geoms) obj.Shape = sh diff --git a/src/Mod/BIM/ArchMaterial.py b/src/Mod/BIM/ArchMaterial.py index 0c1a1262344f..04862f680762 100644 --- a/src/Mod/BIM/ArchMaterial.py +++ b/src/Mod/BIM/ArchMaterial.py @@ -272,12 +272,18 @@ def onChanged(self,obj,prop): def execute(self,obj): if obj.Material: if FreeCAD.GuiUp: + c = None + t = None if "DiffuseColor" in obj.Material: - c = tuple([float(f) for f in obj.Material['DiffuseColor'].strip("()").strip("[]").split(",")]) - for p in obj.InList: - if hasattr(p,"Material") and ( (not hasattr(p.ViewObject,"UseMaterialColor")) or p.ViewObject.UseMaterialColor): - if p.Material.Name == obj.Name: - p.ViewObject.ShapeColor = c + c = tuple([float(f) for f in obj.Material["DiffuseColor"].strip("()").strip("[]").split(",")]) + if "Transparency" in obj.Material: + t = int(obj.Material["Transparency"]) + for p in obj.InList: + if hasattr(p,"Material") \ + and p.Material.Name == obj.Name \ + and getattr(obj.ViewObject,"UseMaterialColor",True): + if c: p.ViewObject.ShapeColor = c + if t: p.ViewObject.Transparency = t return def dumps(self): diff --git a/src/Mod/BIM/ArchRoof.py b/src/Mod/BIM/ArchRoof.py index 31fb61f8f4d7..86d12b614b30 100644 --- a/src/Mod/BIM/ArchRoof.py +++ b/src/Mod/BIM/ArchRoof.py @@ -320,11 +320,11 @@ def calcApex(self, i, numEdges): runs = [] if ((not 0 <= profilNext2["idrel"] < numEdges) and 0.0 < profilNext2["angle"] < 90.0 - and vecCurr.getAngle(vecNext2) == math.pi): + and math.isclose(vecCurr.getAngle(vecNext2), math.pi, abs_tol=1e-7)): runs.append((self.helperCalcApex(profilCurr, profilNext2))) if ((not 0 <= profilBack2["idrel"] < numEdges) and 0.0 < profilBack2["angle"] < 90.0 - and vecCurr.getAngle(vecBack2) == math.pi): + and math.isclose(vecCurr.getAngle(vecBack2), math.pi, abs_tol=1e-7)): runs.append((self.helperCalcApex(profilCurr, profilBack2))) runs.sort() if len(runs) != 0 and runs[0] != profilCurr["run"]: diff --git a/src/Mod/BIM/ArchSchedule.py b/src/Mod/BIM/ArchSchedule.py index eed79ea454b6..071d01a6b8f4 100644 --- a/src/Mod/BIM/ArchSchedule.py +++ b/src/Mod/BIM/ArchSchedule.py @@ -537,9 +537,6 @@ def __init__(self,obj=None): mw = FreeCADGui.getMainWindow() self.form.move(mw.frameGeometry().topLeft() + mw.rect().center() - self.form.rect().center()) - # maintain above FreeCAD window - self.form.setWindowFlags(self.form.windowFlags() | QtCore.Qt.WindowStaysOnTopHint) - self.form.show() def add(self): diff --git a/src/Mod/BIM/ArchSectionPlane.py b/src/Mod/BIM/ArchSectionPlane.py index bdb149cb60fa..2d31f2da9a9e 100644 --- a/src/Mod/BIM/ArchSectionPlane.py +++ b/src/Mod/BIM/ArchSectionPlane.py @@ -1145,7 +1145,7 @@ def setupContextMenu(self, vobj, menu): actionToggleCutview = QtGui.QAction(QtGui.QIcon(":/icons/Draft_Edit.svg"), translate("Arch", "Toggle Cutview"), menu) - actionToggleCutview.triggered.connect(lambda f=self.toggleCutview, arg=vobj: f(arg)) + actionToggleCutview.triggered.connect(lambda: self.toggleCutview(vobj)) menu.addAction(actionToggleCutview) def edit(self): diff --git a/src/Mod/BIM/bimcommands/BimLeader.py b/src/Mod/BIM/bimcommands/BimLeader.py index 7fac7446af57..f198dff9f1b9 100644 --- a/src/Mod/BIM/bimcommands/BimLeader.py +++ b/src/Mod/BIM/bimcommands/BimLeader.py @@ -52,45 +52,26 @@ def Activated(self): def finish(self, closed=False, cont=False): import DraftVecUtils + from draftutils import params self.end_callbacks(self.call) self.removeTemporaryObject() - if getattr(self,"oldWP",None): - FreeCAD.DraftWorkingPlane = self.oldWP - if hasattr(Gui, "Snapper"): - FreeCADGui.Snapper.setGrid() - FreeCADGui.Snapper.restack() - self.oldWP = None - rot, sup, pts, fil = self.getStrings() - if self.node: + if len(self.node) > 1: + rot, sup, pts, fil = self.getStrings() base = DraftVecUtils.toString(self.node[0]) - else: - base = DraftVecUtils.toString(FreeCAD.Vector()) - color = FreeCAD.ParamGet( - "User parameter:BaseApp/Preferences/Mod/Draft" - ).GetUnsigned("DefaultTextColor", 255) - r = ((color >> 24) & 0xFF) / 255.0 - g = ((color >> 16) & 0xFF) / 255.0 - b = ((color >> 8) & 0xFF) / 255.0 - cmd_list = [ - "pl = FreeCAD.Placement()", - "pl.Rotation.Q = " + rot, - "pl.Base = " + base, - "points = " + pts, - "leader = Draft.makeWire(points,placement=pl)", - "leader.ViewObject.LineColor = " - + str( - ( - r, - g, - b, - ) - ), - "leader.ViewObject.EndArrow = True", - "Draft.autogroup(leader)", - "FreeCAD.ActiveDocument.recompute()", - ] - FreeCADGui.addModule("Draft") - self.commit(translate("BIM", "Create Leader"), cmd_list) + color = params.get_param("DefaultTextColor") | 0x000000FF + cmd_list = [ + "pl = FreeCAD.Placement()", + "pl.Rotation.Q = " + rot, + "pl.Base = " + base, + "points = " + pts, + "leader = Draft.make_wire(points, placement=pl)", + "leader.ViewObject.LineColor = " + str(color), + "leader.ViewObject.EndArrow = True", + "Draft.autogroup(leader)", + "FreeCAD.ActiveDocument.recompute()", + ] + FreeCADGui.addModule("Draft") + self.commit(translate("BIM", "Create Leader"), cmd_list) super(gui_lines.Line, self).finish() if self.ui and self.ui.continueMode: self.Activated() diff --git a/src/Mod/BIM/bimcommands/BimProjectManager.py b/src/Mod/BIM/bimcommands/BimProjectManager.py index 24fc94c29941..387ec089619d 100644 --- a/src/Mod/BIM/bimcommands/BimProjectManager.py +++ b/src/Mod/BIM/bimcommands/BimProjectManager.py @@ -375,10 +375,6 @@ def savePreset(self): + "\n" ) s += "groups=" + ";;".join(groups) + "\n" - - s += "levelsWP=" + str(int(self.form.levelsWP.isChecked())) + "\n" - s += "levelsAxis=" + str(int(self.form.levelsAxis.isChecked())) + "\n" - s += ( "addHumanFigure=" + str(int(self.form.addHumanFigure.isChecked())) @@ -468,10 +464,6 @@ def getPreset(self, preset): groups = s[1].split(";;") self.form.groupsList.clear() self.form.groupsList.addItems(groups) - elif s[0] == "levelsWP": - self.form.levelsWP.setChecked(bool(int(s[1]))) - elif s[0] == "levelsAxis": - self.form.levelsAxis.setChecked(bool(int(s[1]))) elif s[0] == "addHumanFigure": self.form.addHumanFigure.setChecked(bool(int(s[1]))) diff --git a/src/Mod/BIM/bimcommands/BimTDPage.py b/src/Mod/BIM/bimcommands/BimTDPage.py index 0c5100ec0e16..3ebf52aab0e9 100644 --- a/src/Mod/BIM/bimcommands/BimTDPage.py +++ b/src/Mod/BIM/bimcommands/BimTDPage.py @@ -102,6 +102,7 @@ def Activated(self): page.Scale = FreeCAD.ParamGet( "User parameter:BaseApp/Preferences/Mod/BIM" ).GetFloat("DefaultPageScale", 0.01) + page.ViewObject.show() FreeCAD.ActiveDocument.recompute() diff --git a/src/Mod/BIM/bimcommands/BimWPCommands.py b/src/Mod/BIM/bimcommands/BimWPCommands.py index bc1e66833baa..36a9d5fb2953 100644 --- a/src/Mod/BIM/bimcommands/BimWPCommands.py +++ b/src/Mod/BIM/bimcommands/BimWPCommands.py @@ -89,7 +89,7 @@ def GetResources(self): "MenuText": QT_TRANSLATE_NOOP("BIM_WPView", "Working Plane View"), "ToolTip": QT_TRANSLATE_NOOP( "BIM_WPView", - "Aligns the view on the current item in BIM Views window or on the current working plane", + "Aligns the view to the current item in BIM Views window or to the current working plane", ), "Accel": "9", } @@ -99,32 +99,22 @@ def IsActive(self): return v def Activated(self): - done = False - try: - import BimViews - except ImportError: - pass - else: - v = BimViews.findWidget() - if v: - i = v.tree.currentItem() - if i: - # Aligning on current widget item - BimViews.show(i) - done = True - elif hasattr(v, "lastSelected"): - BimViews.show(v.lastSelected) - # Aligning on stored widget item - done = True - elif hasattr(FreeCAD, "DraftWorkingPlane"): - if hasattr(FreeCAD.DraftWorkingPlane, "lastBuildingPart"): - BimViews.show(FreeCAD.DraftWorkingPlane.lastBuildingPart) - done = True - if not done: - # Aligning on current working plane - c = FreeCADGui.ActiveDocument.ActiveView.getCameraNode() - r = FreeCAD.DraftWorkingPlane.getRotation().Rotation.Q - c.orientation.setValue(r) + from bimcommands import BimViews + import WorkingPlane + + vm = BimViews.findWidget() + if vm: + sel = vm.tree.selectedItems() + if sel: + # Aligning to current widget item + BimViews.show(sel[0]) + return + if hasattr(vm, "lastSelected"): + # Aligning to stored widget item + BimViews.show(vm.lastSelected) + return + # Aligning to current working plane + WorkingPlane.get_working_plane().align_view() FreeCADGui.addCommand("BIM_WPView", BIM_WPView()) diff --git a/src/Mod/BIM/nativeifc/ifc_status.py b/src/Mod/BIM/nativeifc/ifc_status.py index 41ca6defe31d..48804a8243ef 100644 --- a/src/Mod/BIM/nativeifc/ifc_status.py +++ b/src/Mod/BIM/nativeifc/ifc_status.py @@ -307,14 +307,12 @@ def filter_out(objs): nobjs.append(obj) elif obj.isDerivedFrom("Mesh::Feature"): nobjs.append(obj) - elif obj.isDerivedFrom("App::DocumentObjectGroup"): + elif Draft.is_group(obj): if filter_out(obj.Group): # only append groups that contain exportable objects nobjs.append(obj) else: print("DEBUG: Filtering out",obj.Label) - elif obj.isDerivedFrom("Mesh::Feature"): - nobjs.append(obj) elif obj.isDerivedFrom("App::Feature"): if Draft.get_type(obj) in ("Dimension","LinearDimension","Layer","Text","DraftText"): nobjs.append(obj) diff --git a/src/Mod/BIM/nativeifc/ifc_tools.py b/src/Mod/BIM/nativeifc/ifc_tools.py index 01fd1431142f..9de6faa70649 100644 --- a/src/Mod/BIM/nativeifc/ifc_tools.py +++ b/src/Mod/BIM/nativeifc/ifc_tools.py @@ -1334,7 +1334,7 @@ def get_orphan_elements(ifcfile): products = ifcfile.by_type("IfcElement") products = [p for p in products if not p.Decomposes] - products = [p for p in products if not p.ContainedInStructure] + products = [p for p in products if not getattr(p, "ContainedInStructure", [])] products = [ p for p in products if not hasattr(p, "VoidsElements") or not p.VoidsElements ] diff --git a/src/Mod/BIM/nativeifc/ifc_viewproviders.py b/src/Mod/BIM/nativeifc/ifc_viewproviders.py index cf6e9385c94a..b0c85bc18c41 100644 --- a/src/Mod/BIM/nativeifc/ifc_viewproviders.py +++ b/src/Mod/BIM/nativeifc/ifc_viewproviders.py @@ -216,7 +216,7 @@ def getOwnChildren(self, obj): """Recursively gets the children only used by this object""" children = [] for child in obj.OutList: - if len(child.InList) == 1 and child.InList[1] == obj: + if len(child.InList) == 1 and child.InList[0] == obj: children.append(child) children.extend(self.getOwnChildren(child)) return children diff --git a/src/Mod/CAM/App/AreaPyImp.cpp b/src/Mod/CAM/App/AreaPyImp.cpp index 0775160615d0..8f5b9dc86017 100644 --- a/src/Mod/CAM/App/AreaPyImp.cpp +++ b/src/Mod/CAM/App/AreaPyImp.cpp @@ -666,7 +666,7 @@ Py::List AreaPy::getShapes() const Area* area = getAreaPtr(); const std::list& shapes = area->getChildren(); for (auto& s : shapes) { - ret.append(Py::TupleN(Part::shape2pyshape(s.shape), Py::Int(s.op))); + ret.append(Py::TupleN(Part::shape2pyshape(s.shape), Py::Long(s.op))); } return ret; } diff --git a/src/Mod/CAM/App/VoronoiCellPy.xml b/src/Mod/CAM/App/VoronoiCellPy.xml index 71c5df4b3080..45643bd857be 100644 --- a/src/Mod/CAM/App/VoronoiCellPy.xml +++ b/src/Mod/CAM/App/VoronoiCellPy.xml @@ -39,7 +39,7 @@ Returns the cell's category as an integer - + diff --git a/src/Mod/CAM/App/VoronoiCellPyImp.cpp b/src/Mod/CAM/App/VoronoiCellPyImp.cpp index 3d34e3950ebf..8999a1b0ffe8 100644 --- a/src/Mod/CAM/App/VoronoiCellPyImp.cpp +++ b/src/Mod/CAM/App/VoronoiCellPyImp.cpp @@ -134,10 +134,10 @@ Py::Long VoronoiCellPy::getSourceIndex() const return Py::Long(index); } -Py::Int VoronoiCellPy::getSourceCategory() const +Py::Long VoronoiCellPy::getSourceCategory() const { VoronoiCell* c = getVoronoiCellFromPy(this); - return Py::Int(c->ptr->source_category()); + return Py::Long(c->ptr->source_category()); } Py::String VoronoiCellPy::getSourceCategoryName() const diff --git a/src/Mod/CAM/Path/Op/Drilling.py b/src/Mod/CAM/Path/Op/Drilling.py index ae17156cba2d..274784de0a6b 100644 --- a/src/Mod/CAM/Path/Op/Drilling.py +++ b/src/Mod/CAM/Path/Op/Drilling.py @@ -309,9 +309,6 @@ def circularHoleExecute(self, obj, holes): # Cancel canned drilling cycle self.commandlist.append(Path.Command("G80")) - command = Path.Command("G0", {"Z": obj.SafeHeight.Value}) - self.commandlist.append(command) - machine.addCommand(command) # Apply feedrates to commands PathFeedRate.setFeedRate(self.commandlist, obj.ToolController) diff --git a/src/Mod/CAM/Path/Post/Command.py b/src/Mod/CAM/Path/Post/Command.py index 6ec9582cd1a6..cfe7272df90e 100644 --- a/src/Mod/CAM/Path/Post/Command.py +++ b/src/Mod/CAM/Path/Post/Command.py @@ -131,7 +131,7 @@ def _write_file(self, filename, gcode, policy): if dlg.exec_(): filename = dlg.selectedFiles()[0] Path.Log.debug(filename) - with open(filename, "w") as f: + with open(filename, "w", encoding="utf-8") as f: f.write(gcode) else: return @@ -140,7 +140,7 @@ def _write_file(self, filename, gcode, policy): while os.path.isfile(filename): base, ext = os.path.splitext(filename) filename = f"{base}-1{ext}" - with open(filename, "w") as f: + with open(filename, "w", encoding="utf-8") as f: f.write(gcode) elif policy == "Open File Dialog on conflict": @@ -153,16 +153,16 @@ def _write_file(self, filename, gcode, policy): if dlg.exec_(): filename = dlg.selectedFiles()[0] Path.Log.debug(filename) - with open(filename, "w") as f: + with open(filename, "w", encoding="utf-8") as f: f.write(gcode) else: return else: - with open(filename, "w") as f: + with open(filename, "w", encoding="utf-8") as f: f.write(gcode) else: # Overwrite - with open(filename, "w") as f: + with open(filename, "w", encoding="utf-8") as f: f.write(gcode) FreeCAD.Console.PrintMessage(f"File written to {filename}\n") diff --git a/src/Mod/Draft/draftviewproviders/view_dimension.py b/src/Mod/Draft/draftviewproviders/view_dimension.py index 2526da2ece71..2803aea29bb9 100644 --- a/src/Mod/Draft/draftviewproviders/view_dimension.py +++ b/src/Mod/Draft/draftviewproviders/view_dimension.py @@ -723,11 +723,6 @@ def draw_dim_arrows(self, vobj): if not hasattr(vobj, "ArrowType"): return - if self.p3.x < self.p2.x: - inv = False - else: - inv = True - # Set scale symbol = utils.ARROW_TYPES.index(vobj.ArrowType) s = vobj.ArrowSize.Value * vobj.ScaleMultiplier @@ -745,7 +740,7 @@ def draw_dim_arrows(self, vobj): else: s1.addChild(self.trans1) - s1.addChild(gui_utils.dim_symbol(symbol, invert=not inv)) + s1.addChild(gui_utils.dim_symbol(symbol, invert=False)) self.marks.addChild(s1) s2 = coin.SoSeparator() @@ -754,7 +749,7 @@ def draw_dim_arrows(self, vobj): else: s2.addChild(self.trans2) - s2.addChild(gui_utils.dim_symbol(symbol, invert=inv)) + s2.addChild(gui_utils.dim_symbol(symbol, invert=True)) self.marks.addChild(s2) self.node_wld.insertChild(self.marks, 2) diff --git a/src/Mod/Import/App/dxf/dxf.cpp b/src/Mod/Import/App/dxf/dxf.cpp index 8dab4113378b..7b0bc49b3bb5 100644 --- a/src/Mod/Import/App/dxf/dxf.cpp +++ b/src/Mod/Import/App/dxf/dxf.cpp @@ -12,11 +12,14 @@ #include #include #include +#include +#include #include "dxf.h" #include #include #include +#include #include #include #include @@ -2564,6 +2567,12 @@ bool CDxfRead::ResolveEncoding() // Also some DXF files have the codepage name in uppercase so we lowercase it. m_encoding = m_CodePage; std::transform(m_encoding.begin(), m_encoding.end(), m_encoding.begin(), ::tolower); + + // Add mapping for common non-standard encoding names. + if (m_encoding == "8859_1") { + m_encoding = "iso-8859-1"; // Replace with a name Python understands + } + // NOLINTNEXTLINE(readability/nolint) #define ANSI_ENCODING_PREFIX "ansi_" // NOLINT(cppcoreguidelines-macro-usage) if (m_encoding.rfind(ANSI_ENCODING_PREFIX, 0) == 0 && m_encoding.rfind("ansi_x3", 0) != 0) { @@ -2579,7 +2588,11 @@ bool CDxfRead::ResolveEncoding() Base::PyGILStateLocker lock; PyObject* pyDecoder = PyCodec_Decoder(m_encoding.c_str()); if (pyDecoder == nullptr) { - return false; // A key error exception will have been placed. + // PyCodec_Decoder failed, which means Python could not find the encoding. + // This sets a Python LookupError. We clear this low-level error because + // our caller will throw a more informative, high-level exception. + PyErr_Clear(); + return false; } PyObject* pyUTF8Decoder = PyCodec_Decoder("utf_8"); assert(pyUTF8Decoder != nullptr); @@ -2628,64 +2641,98 @@ void CDxfRead::DoRead(const bool ignore_errors /* = false */) return; } - StartImport(); - // Loop reading the sections. - while (get_next_record()) { - if (m_record_type != eObjectType) { - ImportError("Found type %d record when expecting start of a SECTION or EOF\n", - (int)m_record_type); - continue; - } - if (IsObjectName("EOF")) { // TODO: Check for drivel beyond EOF record - break; - } - if (!IsObjectName("SECTION")) { - ImportError("Found %s record when expecting start of a SECTION\n", - m_record_data.c_str()); - continue; + try { + StartImport(); + // Loop reading the sections. + while (get_next_record()) { + if (m_record_type != eObjectType) { + ImportError("Found type %d record when expecting start of a SECTION or EOF\n", + (int)m_record_type); + continue; + } + if (IsObjectName("EOF")) { // TODO: Check for drivel beyond EOF record + break; + } + if (!IsObjectName("SECTION")) { + ImportError("Found %s record when expecting start of a SECTION\n", + m_record_data.c_str()); + continue; + } + if (!ReadSection()) { + throw Base::RuntimeError("Failed to read DXF section (returned false)."); + } } - if (!ReadSection()) { - return; + FinishImport(); + + // Flush out any unsupported features messages + if (!m_unsupportedFeaturesNoted.empty()) { + ImportError("Unsupported DXF features:\n"); + for (auto& featureInfo : m_unsupportedFeaturesNoted) { + ImportError("%s: %d time(s) first at line %d\n", + featureInfo.first, + featureInfo.second.first, + featureInfo.second.second); + } } } - FinishImport(); - - // FLush out any unsupported features messages - if (!m_unsupportedFeaturesNoted.empty()) { - ImportError("Unsupported DXF features:\n"); - for (auto& featureInfo : m_unsupportedFeaturesNoted) { - ImportError("%s: %d time(s) first at line %d\n", - featureInfo.first, - featureInfo.second.first, - featureInfo.second.second); - } + catch (const Base::Exception& e) { + // This catches specific FreeCAD exceptions and re-throws them. + throw; + } + catch (const std::exception& e) { + // This catches all standard C++ exceptions and converts them + // to a FreeCAD exception, which the binding layer can handle. + throw Base::RuntimeError(e.what()); + } + catch (...) { + // This is a catch-all for any other non-standard C++ exceptions. + throw Base::RuntimeError( + "An unknown, non-standard C++ exception occurred during DXF import."); } } bool CDxfRead::ReadSection() { if (!get_next_record()) { - ImportError("Unclosed SECTION at end of file\n"); - return false; + throw Base::RuntimeError("Unexpected end of file after SECTION tag."); } if (m_record_type != eName) { ImportError("Ignored SECTION with no name record\n"); return ReadIgnoredSection(); } + if (IsObjectName("HEADER")) { - return ReadHeaderSection(); + if (!ReadHeaderSection()) { + throw Base::RuntimeError("Failed while reading HEADER section."); + } + return true; } if (IsObjectName("TABLES")) { - return ReadTablesSection(); + if (!ReadTablesSection()) { + throw Base::RuntimeError("Failed while reading TABLES section."); + } + return true; } if (IsObjectName("BLOCKS")) { - return ReadBlocksSection(); + if (!ReadBlocksSection()) { + throw Base::RuntimeError("Failed while reading BLOCKS section."); + } + return true; } if (IsObjectName("ENTITIES")) { - return ReadEntitiesSection(); + if (!ReadEntitiesSection()) { + throw Base::RuntimeError("Failed while reading ENTITIES section."); + } + return true; } - return ReadIgnoredSection(); + + if (!ReadIgnoredSection()) { + throw Base::RuntimeError("Failed while reading an unknown/ignored section."); + } + + return true; } + void CDxfRead::ProcessLayerReference(CDxfRead* object, void* target) { if (object->Layers.count(object->m_record_data) == 0) { @@ -2774,11 +2821,18 @@ bool CDxfRead::ReadHeaderSection() if (m_record_type != eVariableName) { continue; // Quietly ignore unknown record types } + + // Store the variable name before we try to read its value. + std::string currentVarName = m_record_data; if (!ReadVariable()) { - return false; + // If ReadVariable returns false, throw an exception with the variable name. + throw Base::RuntimeError("Failed while reading value for HEADER variable: " + + currentVarName); } } - return false; + + // If the loop finishes without finding ENDSEC, it's an error. + throw Base::RuntimeError("Unexpected end of file inside HEADER section."); } bool CDxfRead::ReadVariable() diff --git a/src/Mod/Material/App/Array2DPy.xml b/src/Mod/Material/App/Array2DPy.xml index c4d066b17bfc..c9beb5580d4a 100644 --- a/src/Mod/Material/App/Array2DPy.xml +++ b/src/Mod/Material/App/Array2DPy.xml @@ -25,13 +25,13 @@ The number of rows in the array. - + The number of columns in the array. - + diff --git a/src/Mod/Material/App/Array2DPyImp.cpp b/src/Mod/Material/App/Array2DPyImp.cpp index 8f286d6f4a63..3b576be1cad7 100644 --- a/src/Mod/Material/App/Array2DPyImp.cpp +++ b/src/Mod/Material/App/Array2DPyImp.cpp @@ -81,14 +81,14 @@ Py::List Array2DPy::getArray() const return list; } -Py::Int Array2DPy::getRows() const +Py::Long Array2DPy::getRows() const { - return Py::Int(getMaterial2DArrayPtr()->rows()); + return Py::Long(getMaterial2DArrayPtr()->rows()); } -Py::Int Array2DPy::getColumns() const +Py::Long Array2DPy::getColumns() const { - return Py::Int(getMaterial2DArrayPtr()->columns()); + return Py::Long(getMaterial2DArrayPtr()->columns()); } PyObject* Array2DPy::getRow(PyObject* args) diff --git a/src/Mod/Material/App/Array3DPy.xml b/src/Mod/Material/App/Array3DPy.xml index b6d55f42edf5..435c61e06a5f 100644 --- a/src/Mod/Material/App/Array3DPy.xml +++ b/src/Mod/Material/App/Array3DPy.xml @@ -25,13 +25,13 @@ The number of columns in the array. - + The depth of the array (3rd dimension). - + diff --git a/src/Mod/Material/App/Array3DPyImp.cpp b/src/Mod/Material/App/Array3DPyImp.cpp index c1a956da5b54..bb6e57ee43a3 100644 --- a/src/Mod/Material/App/Array3DPyImp.cpp +++ b/src/Mod/Material/App/Array3DPyImp.cpp @@ -83,14 +83,14 @@ Py::List Array3DPy::getArray() const return list; } -Py::Int Array3DPy::getColumns() const +Py::Long Array3DPy::getColumns() const { - return Py::Int(getMaterial3DArrayPtr()->columns()); + return Py::Long(getMaterial3DArrayPtr()->columns()); } -Py::Int Array3DPy::getDepth() const +Py::Long Array3DPy::getDepth() const { - return Py::Int(getMaterial3DArrayPtr()->depth()); + return Py::Long(getMaterial3DArrayPtr()->depth()); } PyObject* Array3DPy::getRows(PyObject* args) diff --git a/src/Mod/Measure/App/MeasurePosition.cpp b/src/Mod/Measure/App/MeasurePosition.cpp index 19195dee00df..806d2a0b15c1 100644 --- a/src/Mod/Measure/App/MeasurePosition.cpp +++ b/src/Mod/Measure/App/MeasurePosition.cpp @@ -95,7 +95,9 @@ App::DocumentObjectExecReturn* MeasurePosition::execute() { const App::DocumentObject* object = Element.getValue(); const std::vector& subElements = Element.getSubValues(); - + if (subElements.empty()) { + return {}; + } App::SubObjectT subject {object, subElements.front().c_str()}; auto info = getMeasureInfo(subject); diff --git a/src/Mod/Part/App/AppPartPy.cpp b/src/Mod/Part/App/AppPartPy.cpp index 20d680b364e2..c9279a9c5bcc 100644 --- a/src/Mod/Part/App/AppPartPy.cpp +++ b/src/Mod/Part/App/AppPartPy.cpp @@ -1048,7 +1048,7 @@ class Module : public Py::ExtensionModule if (!PyLong_Check(value)) { throw Py::ValueError(err); } - int order = Py::Int(value); + int order = Py::Long(value); params.orders[s] = static_cast(order); return; }); @@ -1125,7 +1125,7 @@ class Module : public Py::ExtensionModule if (!PyLong_Check(value)) { throw Py::ValueError(err); } - int order = Py::Int(value); + int order = Py::Long(value); params.orders[s] = static_cast(order); return; }); diff --git a/src/Mod/Part/App/PartFeaturePyImp.cpp b/src/Mod/Part/App/PartFeaturePyImp.cpp index 5d02cc1df0b1..5aec0fc606c0 100644 --- a/src/Mod/Part/App/PartFeaturePyImp.cpp +++ b/src/Mod/Part/App/PartFeaturePyImp.cpp @@ -65,7 +65,7 @@ PyObject *PartFeaturePy::getElementHistory(PyObject *args, PyObject *kwds) { } else ret.setItem(0, Py::Object(history.obj->getPyObject(), true)); } else - ret.setItem(0, Py::Int(history.tag)); + ret.setItem(0, Py::Long(history.tag)); tmp.clear(); ret.setItem(1, Py::String(history.element.appendToBuffer(tmp))); Py::List intermedates; diff --git a/src/Mod/Part/App/TopoShapePyImp.cpp b/src/Mod/Part/App/TopoShapePyImp.cpp index 80131c668e4a..b20571b5af5a 100644 --- a/src/Mod/Part/App/TopoShapePyImp.cpp +++ b/src/Mod/Part/App/TopoShapePyImp.cpp @@ -1889,7 +1889,7 @@ PyObject* TopoShapePy::countElement(PyObject *args) return nullptr; PY_TRY { - return Py::new_reference_to(Py::Int((long)getTopoShapePtr()->countSubShapes(input))); + return Py::new_reference_to(Py::Long((long)getTopoShapePtr()->countSubShapes(input))); } PY_CATCH_OCC } @@ -2362,10 +2362,10 @@ PyObject* TopoShapePy::findSubShape(PyObject* args) for (auto& s : getPyShapes(pyobj)) { int index = getTopoShapePtr()->findShape(s.getShape()); if (index > 0) { - res.append(Py::TupleN(Py::String(s.shapeName()), Py::Int(index))); + res.append(Py::TupleN(Py::String(s.shapeName()), Py::Long(index))); } else { - res.append(Py::TupleN(Py::Object(), Py::Int(0))); + res.append(Py::TupleN(Py::Object(), Py::Long(0))); } } if (PySequence_Check(pyobj)) { @@ -2652,7 +2652,7 @@ PyObject* TopoShapePy::getElementHistory(PyObject* args) Py_Return; } Py::Tuple ret(3); - ret.setItem(0, Py::Int(tag)); + ret.setItem(0, Py::Long(tag)); std::string tmp; ret.setItem(1, Py::String(original.appendToBuffer(tmp))); Py::List pyHistory; diff --git a/src/Mod/Points/Gui/Command.cpp b/src/Mod/Points/Gui/Command.cpp index 02f159739677..9d70da4ced2e 100644 --- a/src/Mod/Points/Gui/Command.cpp +++ b/src/Mod/Points/Gui/Command.cpp @@ -81,7 +81,7 @@ void CmdPointsImport::activated(int iMsg) Gui::getMainWindow(), QString(), QString(), - QString::fromLatin1("%1 (*.asc *.pcd *.ply);;%2 (*.*)") + QStringLiteral("%1 (*.asc *.pcd *.ply *.e57);;%2 (*.*)") .arg(QObject::tr("Point formats"), QObject::tr("All Files"))); if (fn.isEmpty()) { return; diff --git a/src/Mod/Sandbox/Gui/AppSandboxGui.cpp b/src/Mod/Sandbox/Gui/AppSandboxGui.cpp index 848ec3169fe3..dd9340547fba 100644 --- a/src/Mod/Sandbox/Gui/AppSandboxGui.cpp +++ b/src/Mod/Sandbox/Gui/AppSandboxGui.cpp @@ -114,7 +114,7 @@ class ObjectObserver : public App::DocumentObserver args.setItem(3,vector.apply(xyz)); args.setItem(4,Py::Float(radius)); - args.setItem(5,Py::Int((int)0)); + args.setItem(5,Py::Long((int)0)); Py::Tuple ret(method.apply(args)); Py::Object S1(ret.getItem(0)); Py::Object S2(ret.getItem(1)); @@ -154,7 +154,7 @@ class ObjectObserver : public App::DocumentObserver args.setItem(2,Py::Vector(l2)); args.setItem(3,Py::Vector(Base::Vector3d(0,0,1))); args.setItem(4,Py::Float(radius)); - //args.setItem(5,Py::Int((int)0)); + //args.setItem(5,Py::Long((int)0)); args.setItem(5,Py::Long((long)1)); Py::Tuple ret(method.apply(args)); Py::Vector S1(ret.getItem(0)); diff --git a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp index 56e6af78da09..48df945af063 100644 --- a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp +++ b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp @@ -2399,7 +2399,7 @@ Py::List SketchObjectPy::getConflictingConstraints() const Py::List conflicting; for (auto cid : conflictinglist) { - conflicting.append(Py::Int(cid)); + conflicting.append(Py::Long(cid)); } return conflicting; @@ -2412,7 +2412,7 @@ Py::List SketchObjectPy::getRedundantConstraints() const Py::List redundant; for (auto cid : redundantlist) { - redundant.append(Py::Int(cid)); + redundant.append(Py::Long(cid)); } return redundant; @@ -2425,7 +2425,7 @@ Py::List SketchObjectPy::getPartiallyRedundantConstraints() const Py::List redundant; for (auto cid : redundantlist) { - redundant.append(Py::Int(cid)); + redundant.append(Py::Long(cid)); } return redundant; @@ -2438,7 +2438,7 @@ Py::List SketchObjectPy::getMalformedConstraints() const Py::List malformed; for (auto cid : malformedlist) { - malformed.append(Py::Int(cid)); + malformed.append(Py::Long(cid)); } return malformed; diff --git a/src/Mod/Sketcher/App/SketchPyImp.cpp b/src/Mod/Sketcher/App/SketchPyImp.cpp index 5d25ea726b9c..88c6414b16b7 100644 --- a/src/Mod/Sketcher/App/SketchPyImp.cpp +++ b/src/Mod/Sketcher/App/SketchPyImp.cpp @@ -178,7 +178,7 @@ PyObject* SketchPy::movePoint(PyObject* args) Py::Long SketchPy::getConstraint() const { - // return Py::Int(); + // return Py::Long(); throw Py::AttributeError("Not yet implemented"); } diff --git a/src/Mod/TechDraw/CSVdata/FillTemplateFields.csv b/src/Mod/TechDraw/CSVdata/FillTemplateFields.csv index 3efbd89d3a95..0135a9bfbcef 100644 --- a/src/Mod/TechDraw/CSVdata/FillTemplateFields.csv +++ b/src/Mod/TechDraw/CSVdata/FillTemplateFields.csv @@ -1,10 +1,11 @@ CreatedByChkLst,ScaleChkLst,LabelChkLst,CommentChkLst,CompanyChkLst,LicenseChkLst,CreatedDateChkLst,LastModifiedDateChkLst "author_name","fc-sc","drawing_title","freecad_drawing","nomsuperviseur","copyright","datedecreation","fc-date" -"nomauteur","echelle","document_type","titleline-1","companyname","rights","fecha2","date" +"nomauteur","echelle","title","titleline-1","companyname","rights","fecha2","date" "authorname","масштаб","titre","sous_titre","compagnyname",,"date-1","dateverification" "designed_by_name","escala","название","subtitulo","compagny",,"creationdate","дата" "designed by name","scale","titulo", "subtitle",,,,"fecha3" -"nom auteur","fc-scale","drawing_name",,,,,"date-2" -,,"fc-title",,,,,"checkdate" -,,"titleline-1",,,,, +"nom auteur","fc-scale","drawing_name","supplementary_title_1",,,,"date-2" +"creator",,"fc-title",,,,,"checkdate" +,,"titleline-1",,,,,"date_of_issue" ,,"freecad",,,,, +,,"document_type",,,,, diff --git a/src/Mod/TechDraw/Gui/QGCustomText.cpp b/src/Mod/TechDraw/Gui/QGCustomText.cpp index 07e13a881f49..895ec1c50925 100644 --- a/src/Mod/TechDraw/Gui/QGCustomText.cpp +++ b/src/Mod/TechDraw/Gui/QGCustomText.cpp @@ -178,7 +178,7 @@ void QGCustomText::paint ( QPainter * painter, const QStyleOptionGraphicsItem * myOption.state &= ~QStyle::State_Selected; // painter->setPen(Qt::green); -// painter->drawRect(boundingRect()); //good for debugging +// painter->drawRect(alignmentRect()); //good for debugging QGraphicsTextItem::paint (painter, &myOption, widget); } diff --git a/src/Mod/TechDraw/Gui/QGIViewDimension.cpp b/src/Mod/TechDraw/Gui/QGIViewDimension.cpp index 327720dc39c9..4fb45deae64c 100644 --- a/src/Mod/TechDraw/Gui/QGIViewDimension.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewDimension.cpp @@ -354,18 +354,29 @@ QRectF QGIDatumLabel::boundingRect() const return childrenBoundingRect(); } -void QGIDatumLabel::updateFrameRect() { - prepareGeometryChange(); +QRectF QGIDatumLabel::tightBoundingRect() const +{ + QRectF totalRect; + for (QGraphicsItem* item : m_textItems->childItems()) { + auto* customText = dynamic_cast(item); + if (customText && !customText->toPlainText().isEmpty()) { + QRectF itemRect = customText->alignmentRect(); + QPointF pos = customText->pos(); + itemRect.translate(pos.x(), pos.y()); + totalRect = totalRect.isNull() ? itemRect : totalRect.united(itemRect); + } + } int fontSize = m_dimText->font().pixelSize(); - int paddingLeft = fontSize * 0.3; + int paddingLeft = fontSize * 0.2; int paddingTop = fontSize * 0.1; - int paddingRight = fontSize * 0.3; - int paddingBottom = fontSize * 0.125; - // Why top and bottom padding different? - // Because the m_dimText bouding box isn't relative to X height :( - // And we want padding to be relative to X height - // TODO: make QGCustomLabel::boundingBoxXHeight - m_frame->setRect(m_textItems->childrenBoundingRect().adjusted(-paddingLeft, -paddingTop, paddingRight, paddingBottom)); // Update bouding rect + int paddingRight = fontSize * 0.2; + int paddingBottom = fontSize * 0.1; + return totalRect.adjusted(-paddingLeft, -paddingTop, paddingRight, paddingBottom); +} + +void QGIDatumLabel::updateFrameRect() { + prepareGeometryChange(); + m_frame->setRect(tightBoundingRect()); } void QGIDatumLabel::setLineWidth(double lineWidth) @@ -466,7 +477,7 @@ void QGIDatumLabel::setFont(QFont font) QFont tFont(font); double fontSize = font.pixelSize(); double tolAdj = getTolAdjust(); - tFont.setPixelSize((int)(fontSize * tolAdj)); + tFont.setPixelSize(std::max(1, (int)(fontSize * tolAdj))); m_tolTextOver->setFont(tFont); m_tolTextUnder->setFont(tFont); updateFrameRect(); diff --git a/src/Mod/TechDraw/Gui/QGIViewDimension.h b/src/Mod/TechDraw/Gui/QGIViewDimension.h index 7dcb13660a29..70a8efca50af 100644 --- a/src/Mod/TechDraw/Gui/QGIViewDimension.h +++ b/src/Mod/TechDraw/Gui/QGIViewDimension.h @@ -69,6 +69,7 @@ Q_OBJECT int type() const override { return Type;} QRectF boundingRect() const override; + QRectF tightBoundingRect() const; void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, diff --git a/src/Mod/TechDraw/TechDrawTools/TaskFillTemplateFields.py b/src/Mod/TechDraw/TechDrawTools/TaskFillTemplateFields.py index 9982b5ee74db..c829115cb9ad 100644 --- a/src/Mod/TechDraw/TechDrawTools/TaskFillTemplateFields.py +++ b/src/Mod/TechDraw/TechDrawTools/TaskFillTemplateFields.py @@ -152,7 +152,10 @@ def __init__(self): self.la.addWidget(t1, 0, 0) self.cb1 = QtGui.QCheckBox(updateCb) self.cb1.setObjectName(key) - self.cb1.setChecked(QtCore.Qt.Checked) + if hasattr(self.cb1, "setCheckState"): + self.cb1.setCheckState(QtCore.Qt.Checked) + else: + self.cb1.setChecked(QtCore.Qt.Checked) self.la.addWidget(self.cb1, 0, 1) u1 = QtGui.QLabel(updateTxt) self.la.addWidget(u1, 0, 2) @@ -169,7 +172,10 @@ def __init__(self): self.la.addWidget(t2, 1, 0) self.cb2 = QtGui.QCheckBox(updateCb) self.cb2.setObjectName(key) - self.cb2.setChecked(QtCore.Qt.Checked) + if hasattr(self.cb2, "setCheckState"): + self.cb2.setCheckState(QtCore.Qt.Checked) + else: + self.cb2.setChecked(QtCore.Qt.Checked) self.la.addWidget(self.cb2, 1, 1) u2 = QtGui.QLabel(updateTxt) self.la.addWidget(u2, 1, 2) @@ -189,7 +195,10 @@ def __init__(self): self.la.addWidget(t3, 2, 0) self.cb3 = QtGui.QCheckBox(updateCb) self.cb3.setObjectName(key) - self.cb3.setChecked(QtCore.Qt.Checked) + if hasattr(self.cb3, "setCheckState"): + self.cb3.setCheckState(QtCore.Qt.Checked) + else: + self.cb3.setChecked(QtCore.Qt.Checked) self.la.addWidget(self.cb3, 2, 1) u3 = QtGui.QLabel(updateTxt) self.la.addWidget(u3, 2, 2) @@ -206,7 +215,10 @@ def __init__(self): self.la.addWidget(t4, 3, 0) self.cb4 = QtGui.QCheckBox(updateCb) self.cb4.setObjectName(key) - self.cb4.setChecked(QtCore.Qt.Checked) + if hasattr(self.cb4, "setCheckState"): + self.cb4.setCheckState(QtCore.Qt.Checked) + else: + self.cb4.setChecked(QtCore.Qt.Checked) self.la.addWidget(self.cb4, 3, 1) u4 = QtGui.QLabel(updateTxt) self.la.addWidget(u4, 3, 2) @@ -223,7 +235,10 @@ def __init__(self): self.la.addWidget(t5, 4, 0) self.cb5 = QtGui.QCheckBox(updateCb) self.cb5.setObjectName(key) - self.cb5.setChecked(QtCore.Qt.Checked) + if hasattr(self.cb5, "setCheckState"): + self.cb5.setCheckState(QtCore.Qt.Checked) + else: + self.cb5.setChecked(QtCore.Qt.Checked) self.la.addWidget(self.cb5, 4, 1) u5 = QtGui.QLabel(updateTxt) self.la.addWidget(u5, 4, 2) @@ -240,7 +255,10 @@ def __init__(self): self.la.addWidget(t6, 5, 0) self.cb6 = QtGui.QCheckBox(updateCb) self.cb6.setObjectName(key) - self.cb6.setChecked(QtCore.Qt.Checked) + if hasattr(self.cb6, "setCheckState"): + self.cb6.setCheckState(QtCore.Qt.Checked) + else: + self.cb6.setChecked(QtCore.Qt.Checked) self.la.addWidget(self.cb6, 5, 1) u6 = QtGui.QLabel(updateTxt) self.la.addWidget(u6, 5, 2) @@ -257,7 +275,10 @@ def __init__(self): self.la.addWidget(t7, 6, 0) self.cb7 = QtGui.QCheckBox(updateCb) self.cb7.setObjectName(key) - self.cb7.setChecked(QtCore.Qt.Checked) + if hasattr(self.cb7, "setCheckState"): + self.cb7.setCheckState(QtCore.Qt.Checked) + else: + self.cb7.setChecked(QtCore.Qt.Checked) self.la.addWidget(self.cb7, 6, 1) u7 = QtGui.QLabel(updateTxt) self.la.addWidget(u7, 6, 2) @@ -303,7 +324,10 @@ def __init__(self): self.la.addWidget(t8, 7, 0) self.cb8 = QtGui.QCheckBox(updateCb) self.cb8.setObjectName(key) - self.cb8.setChecked(QtCore.Qt.Checked) + if hasattr(self.cb8, "setCheckState"): + self.cb8.setCheckState(QtCore.Qt.Checked) + else: + self.cb8.setChecked(QtCore.Qt.Checked) self.la.addWidget(self.cb8, 7, 1) u8 = QtGui.QLabel(updateTxt) self.la.addWidget(u8, 7, 2) @@ -350,7 +374,10 @@ def __init__(self): "Update All", ) ) - self.cbAll.setChecked(QtCore.Qt.Checked) + if hasattr(self.cbAll, "setCheckState"): + self.cbAll.setCheckState(QtCore.Qt.Checked) + else: + self.cbAll.setChecked(QtCore.Qt.Checked) self.la.addWidget(self.cbAll, 8, 1) self.cbAll.clicked.connect(self.on_cbAll_clicked) @@ -391,11 +418,17 @@ def __init__(self): def on_cbAll_clicked(self): if self.cbAll.isChecked(): for cbEach in self.checkBoxList: - cbEach.setChecked(QtCore.Qt.Checked) + if hasattr(cbEach, "setCheckState"): + cbEach.setCheckState(QtCore.Qt.Checked) + else: + cbEach.setChecked(QtCore.Qt.Checked) self.button.setEnabled(True) else: for cbEach in self.checkBoxList: - cbEach.setChecked(QtCore.Qt.Unchecked) + if hasattr(cbEach, "setCheckState"): + cbEach.setCheckState(QtCore.Qt.Checked) + else: + cbEach.setChecked(QtCore.Qt.Checked) self.button.setEnabled(False) def on_cb1_clicked(self): diff --git a/tests/src/App/Application.cpp b/tests/src/App/Application.cpp index df69f5ea7eec..8ec087360185 100644 --- a/tests/src/App/Application.cpp +++ b/tests/src/App/Application.cpp @@ -2,41 +2,54 @@ #define FC_OS_MACOSX 1 #include "App/ProgramOptionsUtilities.h" +#include + + using namespace App::Util; using Spr = std::pair; -TEST(ApplicationTest, fCustomSyntaxLookup) + +class ApplicationTest: public ::testing::Test +{ +protected: + static void SetUpTestSuite() + { + tests::initApplication(); + } +}; + +TEST_F(ApplicationTest, fCustomSyntaxLookup) { Spr res {customSyntax("-display")}; Spr exp {"display", "null"}; EXPECT_EQ(res, exp); }; -TEST(ApplicationTest, fCustomSyntaxMac) +TEST_F(ApplicationTest, fCustomSyntaxMac) { Spr res {customSyntax("-psn_stuff")}; Spr exp {"psn", "stuff"}; EXPECT_EQ(res, exp); }; -TEST(ApplicationTest, fCustomSyntaxWidgetCount) +TEST_F(ApplicationTest, fCustomSyntaxWidgetCount) { Spr res {customSyntax("-widgetcount")}; Spr exp {"widgetcount", ""}; EXPECT_EQ(res, exp); } -TEST(ApplicationTest, fCustomSyntaxNotFound) +TEST_F(ApplicationTest, fCustomSyntaxNotFound) { Spr res {customSyntax("-displayx")}; Spr exp {"", ""}; EXPECT_EQ(res, exp); }; -TEST(ApplicationTest, fCustomSyntaxAmpersand) +TEST_F(ApplicationTest, fCustomSyntaxAmpersand) { Spr res {customSyntax("@freddie")}; Spr exp {"response-file", "freddie"}; EXPECT_EQ(res, exp); }; -TEST(ApplicationTest, fCustomSyntaxEmptyIn) +TEST_F(ApplicationTest, fCustomSyntaxEmptyIn) { Spr res {customSyntax("")}; Spr exp {"", ""}; diff --git a/tests/src/App/Expression.cpp b/tests/src/App/Expression.cpp index 96a53bcf0bbe..abdeddf90539 100644 --- a/tests/src/App/Expression.cpp +++ b/tests/src/App/Expression.cpp @@ -1,10 +1,22 @@ #include +#include + #include "App/ExpressionParser.h" #include "App/ExpressionTokenizer.h" + +class Expression: public ::testing::Test +{ +protected: + static void SetUpTestSuite() + { + tests::initApplication(); + } +}; + // clang-format off -TEST(Expression, tokenize) +TEST_F(Expression, tokenize) { EXPECT_EQ(App::ExpressionTokenizer().perform(QString::fromUtf8(""), 10), QString()); // 0.0000 deg- @@ -15,7 +27,7 @@ TEST(Expression, tokenize) EXPECT_EQ(App::ExpressionTokenizer().perform(QString::fromUtf8("0.00000 deg"), 11), QString::fromLatin1("deg")); } -TEST(Expression, tokenizeCompletion) +TEST_F(Expression, tokenizeCompletion) { EXPECT_EQ(App::ExpressionTokenizer().perform(QString::fromUtf8("My Cube"), 7), QString::fromUtf8("MyCube")); EXPECT_EQ(App::ExpressionTokenizer().perform(QString::fromUtf8("My Cube0"), 8), QString::fromUtf8("MyCube0")); @@ -24,7 +36,7 @@ TEST(Expression, tokenizeCompletion) EXPECT_EQ(App::ExpressionTokenizer().perform(QString::fromUtf8("My Cube 1"), 9), QString::fromUtf8("MyCube1")); } -TEST(Expression, tokenizeQuantity) +TEST_F(Expression, tokenizeQuantity) { auto result = App::ExpressionParser::tokenize("0.00000 deg"); EXPECT_EQ(result.size(), 2); @@ -36,7 +48,7 @@ TEST(Expression, tokenizeQuantity) EXPECT_EQ(std::get<2>(result[1]), "deg"); } -TEST(Expression, tokenizeFunc) +TEST_F(Expression, tokenizeFunc) { auto result = App::ExpressionParser::tokenize("sin(0.00000)"); EXPECT_EQ(result.size(), 3); @@ -50,7 +62,7 @@ TEST(Expression, tokenizeFunc) EXPECT_EQ(std::get<2>(result[2]), ")"); } -TEST(Expression, tokenizeOne) +TEST_F(Expression, tokenizeOne) { auto result = App::ExpressionParser::tokenize("1"); EXPECT_EQ(result.size(), 1); @@ -59,7 +71,7 @@ TEST(Expression, tokenizeOne) EXPECT_EQ(std::get<2>(result[0]), "1"); } -TEST(Expression, tokenizeNum) +TEST_F(Expression, tokenizeNum) { auto result = App::ExpressionParser::tokenize("1.2341"); EXPECT_EQ(result.size(), 1); @@ -68,7 +80,7 @@ TEST(Expression, tokenizeNum) EXPECT_EQ(std::get<2>(result[0]), "1.2341"); } -TEST(Expression, tokenizeID) +TEST_F(Expression, tokenizeID) { auto result = App::ExpressionParser::tokenize("Something"); EXPECT_EQ(result.size(), 1); @@ -77,7 +89,7 @@ TEST(Expression, tokenizeID) EXPECT_EQ(std::get<2>(result[0]), "Something"); } -TEST(Expression, tokenizeUnit) +TEST_F(Expression, tokenizeUnit) { auto result = App::ExpressionParser::tokenize("km"); EXPECT_EQ(result.size(), 1); @@ -86,7 +98,7 @@ TEST(Expression, tokenizeUnit) EXPECT_EQ(std::get<2>(result[0]), "km"); } -TEST(Expression, tokenizeUSUnit) +TEST_F(Expression, tokenizeUSUnit) { auto result = App::ExpressionParser::tokenize("\""); EXPECT_EQ(result.size(), 1); @@ -95,7 +107,7 @@ TEST(Expression, tokenizeUSUnit) EXPECT_EQ(std::get<2>(result[0]), "\""); } -TEST(Expression, tokenizeInt) +TEST_F(Expression, tokenizeInt) { auto result = App::ExpressionParser::tokenize("123456"); EXPECT_EQ(result.size(), 1); @@ -104,7 +116,7 @@ TEST(Expression, tokenizeInt) EXPECT_EQ(std::get<2>(result[0]), "123456"); } -TEST(Expression, tokenizePi) +TEST_F(Expression, tokenizePi) { auto result = App::ExpressionParser::tokenize("pi"); EXPECT_EQ(result.size(), 1); @@ -113,7 +125,7 @@ TEST(Expression, tokenizePi) EXPECT_EQ(std::get<2>(result[0]), "pi"); } -TEST(Expression, tokenizeE) +TEST_F(Expression, tokenizeE) { auto result = App::ExpressionParser::tokenize("e"); EXPECT_EQ(result.size(), 1); @@ -122,7 +134,7 @@ TEST(Expression, tokenizeE) EXPECT_EQ(std::get<2>(result[0]), "e"); } -TEST(Expression, tokenizeConstant) +TEST_F(Expression, tokenizeConstant) { auto result = App::ExpressionParser::tokenize("True False true false None"); EXPECT_EQ(result.size(), 5); @@ -135,7 +147,7 @@ TEST(Expression, tokenizeConstant) EXPECT_EQ(std::get<0>(result[4]), App::ExpressionParser::CONSTANT); } -TEST(Expression, tokenizeEqual) +TEST_F(Expression, tokenizeEqual) { auto result = App::ExpressionParser::tokenize("=="); EXPECT_EQ(result.size(), 1); @@ -144,7 +156,7 @@ TEST(Expression, tokenizeEqual) EXPECT_EQ(std::get<2>(result[0]), "=="); } -TEST(Expression, tokenizeNotEqual) +TEST_F(Expression, tokenizeNotEqual) { auto result = App::ExpressionParser::tokenize("!="); EXPECT_EQ(result.size(), 1); @@ -153,7 +165,7 @@ TEST(Expression, tokenizeNotEqual) EXPECT_EQ(std::get<2>(result[0]), "!="); } -TEST(Expression, tokenizeLessThan) +TEST_F(Expression, tokenizeLessThan) { auto result = App::ExpressionParser::tokenize("<"); EXPECT_EQ(result.size(), 1); @@ -162,7 +174,7 @@ TEST(Expression, tokenizeLessThan) EXPECT_EQ(std::get<2>(result[0]), "<"); } -TEST(Expression, tokenizeLessThanEqual) +TEST_F(Expression, tokenizeLessThanEqual) { auto result = App::ExpressionParser::tokenize("<="); EXPECT_EQ(result.size(), 1); @@ -171,7 +183,7 @@ TEST(Expression, tokenizeLessThanEqual) EXPECT_EQ(std::get<2>(result[0]), "<="); } -TEST(Expression, tokenizeGreaterThan) +TEST_F(Expression, tokenizeGreaterThan) { auto result = App::ExpressionParser::tokenize(">"); EXPECT_EQ(result.size(), 1); @@ -180,7 +192,7 @@ TEST(Expression, tokenizeGreaterThan) EXPECT_EQ(std::get<2>(result[0]), ">"); } -TEST(Expression, tokenizeGreaterThanEqual) +TEST_F(Expression, tokenizeGreaterThanEqual) { auto result = App::ExpressionParser::tokenize(">="); EXPECT_EQ(result.size(), 1); @@ -189,7 +201,7 @@ TEST(Expression, tokenizeGreaterThanEqual) EXPECT_EQ(std::get<2>(result[0]), ">="); } -TEST(Expression, tokenizeMinus) +TEST_F(Expression, tokenizeMinus) { auto result = App::ExpressionParser::tokenize("1-1"); EXPECT_EQ(result.size(), 3); @@ -198,7 +210,7 @@ TEST(Expression, tokenizeMinus) EXPECT_EQ(std::get<2>(result[1]), "-"); } -TEST(Expression, tokenizeCell1) +TEST_F(Expression, tokenizeCell1) { auto result = App::ExpressionParser::tokenize("$A$12"); EXPECT_EQ(result.size(), 1); @@ -207,7 +219,7 @@ TEST(Expression, tokenizeCell1) EXPECT_EQ(std::get<2>(result[0]), "$A$12"); } -TEST(Expression, tokenizeCell2) +TEST_F(Expression, tokenizeCell2) { auto result = App::ExpressionParser::tokenize("A$12"); EXPECT_EQ(result.size(), 1); @@ -216,7 +228,7 @@ TEST(Expression, tokenizeCell2) EXPECT_EQ(std::get<2>(result[0]), "A$12"); } -TEST(Expression, tokenizeCell3) +TEST_F(Expression, tokenizeCell3) { auto result = App::ExpressionParser::tokenize("$A12"); EXPECT_EQ(result.size(), 1); @@ -225,7 +237,7 @@ TEST(Expression, tokenizeCell3) EXPECT_EQ(std::get<2>(result[0]), "$A12"); } -TEST(Expression, tokenizeString) +TEST_F(Expression, tokenizeString) { auto result = App::ExpressionParser::tokenize("<>"); EXPECT_EQ(result.size(), 1); @@ -234,27 +246,27 @@ TEST(Expression, tokenizeString) EXPECT_EQ(std::get<2>(result[0]), "<>"); } -TEST(Expression, tokenizeExponent) +TEST_F(Expression, tokenizeExponent) { // TODO } -TEST(Expression, tokenizeNumAndUnit) +TEST_F(Expression, tokenizeNumAndUnit) { // TODO } -TEST(Expression, tokenizePos) +TEST_F(Expression, tokenizePos) { // TODO } -TEST(Expression, tokenizeNeg) +TEST_F(Expression, tokenizeNeg) { // TODO } -TEST(Expression, tokenizePi_rad) +TEST_F(Expression, tokenizePi_rad) { EXPECT_EQ(App::ExpressionTokenizer().perform(QString::fromLatin1("p"), 1), QString::fromLatin1("p")); EXPECT_EQ(App::ExpressionTokenizer().perform(QString::fromLatin1("pi"), 2), QString()); @@ -265,13 +277,13 @@ TEST(Expression, tokenizePi_rad) EXPECT_EQ(App::ExpressionTokenizer().perform(QString::fromLatin1("pi rad"), 2), QString()); } -TEST(Expression, toString) +TEST_F(Expression, toString) { App::UnitExpression expr{nullptr, Base::Quantity{}, "pi rad"}; EXPECT_EQ(expr.toString(), "pi rad"); } -TEST(Expression, test_pi_rad) +TEST_F(Expression, test_pi_rad) { auto constant = std::make_unique(nullptr, "pi"); auto unit = std::make_unique(nullptr, Base::Quantity{}, "rad"); @@ -280,7 +292,7 @@ TEST(Expression, test_pi_rad) op.release(); } -TEST(Expression, test_e_rad) +TEST_F(Expression, test_e_rad) { auto constant = std::make_unique(nullptr, "e"); auto unit = std::make_unique(nullptr, Base::Quantity{}, "rad"); diff --git a/tests/src/Base/Axis.cpp b/tests/src/Base/Axis.cpp index fc3bd398405b..b00aa0f61c82 100644 --- a/tests/src/Base/Axis.cpp +++ b/tests/src/Base/Axis.cpp @@ -1,21 +1,32 @@ #include #include -TEST(Axis, TestDefault) +#include + +class Axis: public ::testing::Test +{ +protected: + static void SetUpTestSuite() + { + tests::initApplication(); + } +}; + +TEST_F(Axis, TestDefault) { Base::Axis axis; EXPECT_EQ(axis.getBase(), Base::Vector3d()); EXPECT_EQ(axis.getDirection(), Base::Vector3d()); } -TEST(Axis, TestCustom) +TEST_F(Axis, TestCustom) { Base::Axis axis(Base::Vector3d(0, 0, 1), Base::Vector3d(1, 1, 1)); EXPECT_EQ(axis.getBase(), Base::Vector3d(0, 0, 1)); EXPECT_EQ(axis.getDirection(), Base::Vector3d(1, 1, 1)); } -TEST(Axis, TestSetter) +TEST_F(Axis, TestSetter) { Base::Axis axis; axis.setBase(Base::Vector3d(0, 0, 1)); @@ -24,7 +35,7 @@ TEST(Axis, TestSetter) EXPECT_EQ(axis.getDirection(), Base::Vector3d(1, 1, 1)); } -TEST(Axis, TestAssign) +TEST_F(Axis, TestAssign) { Base::Axis axis; Base::Axis move; @@ -35,7 +46,7 @@ TEST(Axis, TestAssign) EXPECT_EQ(move.getDirection(), Base::Vector3d(1, 1, 1)); } -TEST(Axis, TestReverse) +TEST_F(Axis, TestReverse) { Base::Axis axis(Base::Vector3d(0, 0, 1), Base::Vector3d(1, 1, 1)); axis.reverse(); @@ -43,7 +54,7 @@ TEST(Axis, TestReverse) EXPECT_EQ(axis.getDirection(), Base::Vector3d(-1, -1, -1)); } -TEST(Axis, TestReversed) +TEST_F(Axis, TestReversed) { Base::Axis axis(Base::Vector3d(0, 0, 1), Base::Vector3d(1, 1, 1)); Base::Axis rev(axis.reversed()); @@ -52,7 +63,7 @@ TEST(Axis, TestReversed) EXPECT_EQ(rev.getDirection(), Base::Vector3d(-1, -1, -1)); } -TEST(Axis, TestMove) +TEST_F(Axis, TestMove) { Base::Axis axis(Base::Vector3d(0, 0, 1), Base::Vector3d(1, 1, 1)); axis.move(Base::Vector3d(1, 2, 3)); @@ -60,7 +71,7 @@ TEST(Axis, TestMove) EXPECT_EQ(axis.getDirection(), Base::Vector3d(1, 1, 1)); } -TEST(Axis, TestMult) +TEST_F(Axis, TestMult) { Base::Axis axis(Base::Vector3d(0, 0, 1), Base::Vector3d(0, 0, 1)); axis *= Base::Placement(Base::Vector3d(1, 1, 1), Base::Rotation(1, 0, 0, 0)); diff --git a/tests/src/Gui/Assistant.cpp b/tests/src/Gui/Assistant.cpp index 8cefbd86656f..2b8df4060cd3 100644 --- a/tests/src/Gui/Assistant.cpp +++ b/tests/src/Gui/Assistant.cpp @@ -2,5 +2,17 @@ #include "Gui/Assistant.h" -TEST(Assistant, first) +#include + + +class Assistant: public ::testing::Test +{ +protected: + static void SetUpTestSuite() + { + tests::initApplication(); + } +}; + +TEST_F(Assistant, first) {} diff --git a/tests/src/Mod/Material/App/TestMaterialFilter.cpp b/tests/src/Mod/Material/App/TestMaterialFilter.cpp index 2d27cd464bb3..cc179f70a085 100644 --- a/tests/src/Mod/Material/App/TestMaterialFilter.cpp +++ b/tests/src/Mod/Material/App/TestMaterialFilter.cpp @@ -45,10 +45,9 @@ class TestMaterialFilter : public ::testing::Test { protected: - static void SetUpTestSuite() { - if (App::Application::GetARGC() == 0) { - tests::initApplication(); - } + static void SetUpTestSuite() + { + tests::initApplication(); } void SetUp() override { @@ -72,6 +71,14 @@ class TestMaterialFilter : public ::testing::Test { hGrp->SetBool("UseMaterialsFromConfigDir", false); hGrp->SetBool("UseMaterialsFromCustomDir", true); + auto param = App::GetApplication().GetParameterGroupByPath( + "User parameter:BaseApp/Preferences/Mod/Material/Editor"); + param->SetBool("ShowFavorites", true); + param->SetBool("ShowRecent", true); + param->SetBool("ShowEmptyFolders", false); + param->SetBool("ShowEmptyLibraries", true); + param->SetBool("ShowLegacy", false); + _materialManager->refresh(); _library = _materialManager->getLibrary(QLatin1String("Custom")); @@ -88,19 +95,33 @@ class TestMaterialFilter : public ::testing::Test { hGrp->SetBool("UseMaterialsFromConfigDir", _useUserDir); hGrp->SetBool("UseMaterialsFromCustomDir", _useCustomDir); + hGrp = App::GetApplication().GetParameterGroupByPath( + "User parameter:BaseApp/Preferences/Mod/Material/Editor"); + hGrp->SetBool("ShowFavorites", _includeFavorites); + hGrp->SetBool("ShowRecent", _includeRecent); + hGrp->SetBool("ShowEmptyFolders", _includeFolders); + hGrp->SetBool("ShowEmptyLibraries", _includeLibraries); + hGrp->SetBool("ShowLegacy", _includeLegacy); + _materialManager->refresh(); } - Materials::ModelManager* _modelManager; - Materials::MaterialManager* _materialManager; + Materials::ModelManager* _modelManager {}; + Materials::MaterialManager* _materialManager {}; std::shared_ptr _library; QString _testMaterialUUID; std::string _customDir; - bool _useBuiltInDir; - bool _useWorkbenchDir; - bool _useUserDir; - bool _useCustomDir; + bool _useBuiltInDir {}; + bool _useWorkbenchDir {}; + bool _useUserDir {}; + bool _useCustomDir {}; + + bool _includeFavorites {}; + bool _includeRecent {}; + bool _includeFolders {}; + bool _includeLibraries {}; + bool _includeLegacy {}; const char* UUIDAcrylicLegacy = ""; // This can't be known until it is loaded const char* UUIDAluminumAppearance = "3c6d0407-66b3-48ea-a2e8-ee843edf0311"; diff --git a/tests/src/Mod/Mesh/App/Mesh.cpp b/tests/src/Mod/Mesh/App/Mesh.cpp index 3d0dea51b166..e7b0bd315d3b 100644 --- a/tests/src/Mod/Mesh/App/Mesh.cpp +++ b/tests/src/Mod/Mesh/App/Mesh.cpp @@ -2,8 +2,19 @@ #include #include +#include + +class MeshTest: public ::testing::Test +{ +protected: + static void SetUpTestSuite() + { + tests::initApplication(); + } +}; + // NOLINTBEGIN(cppcoreguidelines-*,readability-*) -TEST(MeshTest, TestDefault) +TEST_F(MeshTest, TestDefault) { MeshCore::MeshKernel kernel; Base::Vector3f p1 {0, 0, 0}; @@ -16,7 +27,7 @@ TEST(MeshTest, TestDefault) EXPECT_EQ(kernel.CountFacets(), 1); } -TEST(MeshTest, TestGrid1OfPlanarMesh) +TEST_F(MeshTest, TestGrid1OfPlanarMesh) { MeshCore::MeshKernel kernel; Base::Vector3f p1 {0, 0, 0}; @@ -36,7 +47,7 @@ TEST(MeshTest, TestGrid1OfPlanarMesh) EXPECT_EQ(countZ, 1); } -TEST(MeshTest, TestGrid2OfPlanarMesh) +TEST_F(MeshTest, TestGrid2OfPlanarMesh) { MeshCore::MeshKernel kernel; Base::Vector3f p1 {0, 0, 0}; @@ -56,7 +67,7 @@ TEST(MeshTest, TestGrid2OfPlanarMesh) EXPECT_EQ(countZ, 1); } -TEST(MeshTest, TestGrid1OfAlmostPlanarMesh) +TEST_F(MeshTest, TestGrid1OfAlmostPlanarMesh) { MeshCore::MeshKernel kernel; Base::Vector3f p1 {0, 0, 0}; @@ -76,7 +87,7 @@ TEST(MeshTest, TestGrid1OfAlmostPlanarMesh) EXPECT_EQ(countZ, 1); } -TEST(MeshTest, TestGrid2OfAlmostPlanarMesh) +TEST_F(MeshTest, TestGrid2OfAlmostPlanarMesh) { MeshCore::MeshKernel kernel; Base::Vector3f p1 {0, 0, 0}; diff --git a/tests/src/Mod/MeshPart/App/MeshPart.cpp b/tests/src/Mod/MeshPart/App/MeshPart.cpp index 4e8ea0c49053..6614c5d9b6bd 100644 --- a/tests/src/Mod/MeshPart/App/MeshPart.cpp +++ b/tests/src/Mod/MeshPart/App/MeshPart.cpp @@ -5,6 +5,9 @@ #include #include +#include + + QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wextra-semi") QT_WARNING_DISABLE_CLANG("-Woverloaded-virtual") @@ -17,8 +20,16 @@ QT_WARNING_DISABLE_CLANG("-Woverloaded-virtual") #include QT_WARNING_POP +class SMesh: public ::testing::Test +{ +protected: + static void SetUpTestSuite() + { + tests::initApplication(); + } +}; // NOLINTBEGIN -TEST(SMesh, testMefisto) +TEST_F(SMesh, testMefisto) { TopoDS_Solid box = BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Solid(); @@ -64,7 +75,7 @@ TEST(SMesh, testMefisto) delete gen; } -TEST(SMesh, testStdMeshers) +TEST_F(SMesh, testStdMeshers) { TopoDS_Solid box = BRepPrimAPI_MakeBox(10.0, 10.0, 10.0).Solid(); diff --git a/tests/src/Mod/Part/App/TopoDS_Shape.cpp b/tests/src/Mod/Part/App/TopoDS_Shape.cpp index 7b37566bf088..b11913b4bed2 100644 --- a/tests/src/Mod/Part/App/TopoDS_Shape.cpp +++ b/tests/src/Mod/Part/App/TopoDS_Shape.cpp @@ -7,9 +7,20 @@ #include #include +#include + +class TestTopoDS_Shape: public ::testing::Test +{ +protected: + static void SetUpTestSuite() + { + tests::initApplication(); + } +}; + // NOLINTBEGIN // clang-format off -TEST(TopoDS_Shape, TestCastEdgeToVertex) +TEST_F(TestTopoDS_Shape, TestCastEdgeToVertex) { BRepBuilderAPI_MakeEdge mkEdge(gp_Pnt(0, 0, 0), gp_Pnt(10, 0, 0)); TopoDS_Edge edge = mkEdge.Edge(); @@ -18,7 +29,7 @@ TEST(TopoDS_Shape, TestCastEdgeToVertex) EXPECT_TRUE(vertex.IsNull()); } -TEST(TopoDS_Shape, TestCastNullVertex) +TEST_F(TestTopoDS_Shape, TestCastNullVertex) { TopoDS_Vertex vertex1; TopoDS_Vertex vertex2; @@ -26,7 +37,7 @@ TEST(TopoDS_Shape, TestCastNullVertex) EXPECT_TRUE(vertex2.IsNull()); } -TEST(TopoDS_Shape, TestCastNullEdge) +TEST_F(TestTopoDS_Shape, TestCastNullEdge) { TopoDS_Edge edge; TopoDS_Vertex vertex; diff --git a/tests/src/Mod/Part/App/TopoShapeCache.cpp b/tests/src/Mod/Part/App/TopoShapeCache.cpp index 6ac7fd36500b..e886cc785ce3 100644 --- a/tests/src/Mod/Part/App/TopoShapeCache.cpp +++ b/tests/src/Mod/Part/App/TopoShapeCache.cpp @@ -15,7 +15,16 @@ // NOLINTBEGIN(readability-magic-numbers,cppcoreguidelines-avoid-magic-numbers) -TEST(ShapeRelationKey, HistoryTraceTypeComparison) +class ShapeRelationKey: public ::testing::Test +{ +protected: + static void SetUpTestSuite() + { + tests::initApplication(); + } +}; + +TEST_F(ShapeRelationKey, HistoryTraceTypeComparison) { // Arrange Data::MappedName mappedName {"mappedName"}; diff --git a/tools/build/WindowsInstaller/Settings.nsh b/tools/build/WindowsInstaller/Settings.nsh index 1936523819e7..b307c7ab5581 100644 --- a/tools/build/WindowsInstaller/Settings.nsh +++ b/tools/build/WindowsInstaller/Settings.nsh @@ -33,10 +33,10 @@ SetCompressor /SOLID lzma #!define APP_VERSION_PATCH 0 # get version info from freecadcmd -!system "${FILES_FREECAD}\bin\freecadcmd.exe -c $\"print(f'!define APP_VERSION_MAJOR \$\"{App.Version()[0]}\$\"')$\">${__FILEDIR__}\version.nsh" = 0 -!system "${FILES_FREECAD}\bin\freecadcmd.exe -c $\"print(f'!define APP_VERSION_MINOR \$\"{App.Version()[1]}\$\"')$\">>${__FILEDIR__}\version.nsh" = 0 -!system "${FILES_FREECAD}\bin\freecadcmd.exe -c $\"print(f'!define APP_VERSION_PATCH \$\"{App.Version()[2]}\$\"')$\">>${__FILEDIR__}\version.nsh" = 0 -!system "${FILES_FREECAD}\bin\freecadcmd.exe -c $\"print(f'!define APP_VERSION_REVISION \$\"{App.Version()[3].split()[0]}\$\"')$\">>${__FILEDIR__}\version.nsh" = 0 +!system "${FILES_FREECAD}\bin\freecadcmd.exe --safe-mode -c $\"print(f'!define APP_VERSION_MAJOR \$\"{App.Version()[0]}\$\"')$\">${__FILEDIR__}\version.nsh" = 0 +!system "${FILES_FREECAD}\bin\freecadcmd.exe --safe-mode -c $\"print(f'!define APP_VERSION_MINOR \$\"{App.Version()[1]}\$\"')$\">>${__FILEDIR__}\version.nsh" = 0 +!system "${FILES_FREECAD}\bin\freecadcmd.exe --safe-mode -c $\"print(f'!define APP_VERSION_PATCH \$\"{App.Version()[2]}\$\"')$\">>${__FILEDIR__}\version.nsh" = 0 +!system "${FILES_FREECAD}\bin\freecadcmd.exe --safe-mode -c $\"print(f'!define APP_VERSION_REVISION \$\"{App.Version()[3].split()[0]}\$\"')$\">>${__FILEDIR__}\version.nsh" = 0 !include "${__FILEDIR__}\version.nsh" !delfile "${__FILEDIR__}\version.nsh"