From d1b496c90aef1f05a3fd008bfeb2dbc3780b5dce Mon Sep 17 00:00:00 2001 From: WandererFan Date: Mon, 5 Jan 2026 11:39:06 -0500 Subject: [PATCH] Surface: Provide geometry to Measure module (#26479) * [Surf]provide geometry to Measure * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- src/Mod/Part/App/MeasureClient.cpp | 6 +++++ src/Mod/Surface/App/AppSurface.cpp | 5 ++++ src/Mod/Surface/App/CMakeLists.txt | 2 ++ src/Mod/Surface/App/Measure.cpp | 37 +++++++++++++++++++++++++ src/Mod/Surface/App/Measure.h | 43 ++++++++++++++++++++++++++++++ 5 files changed, 93 insertions(+) create mode 100644 src/Mod/Surface/App/Measure.cpp create mode 100644 src/Mod/Surface/App/Measure.h diff --git a/src/Mod/Part/App/MeasureClient.cpp b/src/Mod/Part/App/MeasureClient.cpp index 82c41d81c8..4b1f1bf454 100644 --- a/src/Mod/Part/App/MeasureClient.cpp +++ b/src/Mod/Part/App/MeasureClient.cpp @@ -498,6 +498,7 @@ Part::CallbackRegistrationList Part::MeasureClient::reportLengthCB() callbacks.emplace_back("Part", "Length", MeasureLengthHandler); callbacks.emplace_back("PartDesign", "Length", MeasureLengthHandler); callbacks.emplace_back("Sketcher", "Length", MeasureLengthHandler); + callbacks.emplace_back("Surface", "Length", MeasureLengthHandler); return callbacks; } @@ -507,6 +508,7 @@ Part::CallbackRegistrationList Part::MeasureClient::reportPositionCB() callbacks.emplace_back("Part", "Position", MeasurePositionHandler); callbacks.emplace_back("PartDesign", "Position", MeasurePositionHandler); callbacks.emplace_back("Sketcher", "Position", MeasurePositionHandler); + callbacks.emplace_back("Surface", "Position", MeasurePositionHandler); return callbacks; } @@ -516,6 +518,7 @@ Part::CallbackRegistrationList Part::MeasureClient::reportAreaCB() callbacks.emplace_back("Part", "Area", MeasureAreaHandler); callbacks.emplace_back("PartDesign", "Area", MeasureAreaHandler); callbacks.emplace_back("Sketcher", "Area", MeasureAreaHandler); + callbacks.emplace_back("Surface", "Area", MeasureAreaHandler); return callbacks; } @@ -526,6 +529,7 @@ Part::CallbackRegistrationList Part::MeasureClient::reportAngleCB() callbacks.emplace_back("Part", "Angle", MeasureAngleHandler); callbacks.emplace_back("PartDesign", "Angle", MeasureAngleHandler); callbacks.emplace_back("Sketcher", "Angle", MeasureAngleHandler); + callbacks.emplace_back("Surface", "Angle", MeasureAngleHandler); return callbacks; } @@ -536,6 +540,7 @@ Part::CallbackRegistrationList Part::MeasureClient::reportDistanceCB() callbacks.emplace_back("Part", "Distance", MeasureDistanceHandler); callbacks.emplace_back("PartDesign", "Distance", MeasureDistanceHandler); callbacks.emplace_back("Sketcher", "Distance", MeasureDistanceHandler); + callbacks.emplace_back("Surface", "Distance", MeasureDistanceHandler); return callbacks; } @@ -546,5 +551,6 @@ Part::CallbackRegistrationList Part::MeasureClient::reportRadiusCB() callbacks.emplace_back("Part", "Radius", MeasureRadiusHandler); callbacks.emplace_back("PartDesign", "Radius", MeasureRadiusHandler); callbacks.emplace_back("Sketcher", "Radius", MeasureRadiusHandler); + callbacks.emplace_back("Surface", "Radius", MeasureRadiusHandler); return callbacks; } diff --git a/src/Mod/Surface/App/AppSurface.cpp b/src/Mod/Surface/App/AppSurface.cpp index cf85856acd..cb35469465 100644 --- a/src/Mod/Surface/App/AppSurface.cpp +++ b/src/Mod/Surface/App/AppSurface.cpp @@ -38,6 +38,8 @@ #include "FeatureSections.h" #include "FeatureSewing.h" +#include "Measure.h" + namespace Surface { @@ -87,5 +89,8 @@ PyMOD_INIT_FUNC(Surface) Surface::Sections ::init(); // clang-format on + // connect to unified measurement facility + Surface::Measure ::initialize(); + PyMOD_Return(mod); } diff --git a/src/Mod/Surface/App/CMakeLists.txt b/src/Mod/Surface/App/CMakeLists.txt index e5522e72e8..395324d5b1 100644 --- a/src/Mod/Surface/App/CMakeLists.txt +++ b/src/Mod/Surface/App/CMakeLists.txt @@ -45,6 +45,8 @@ SET(Surface_SRCS FeatureSewing.h FeatureCut.cpp FeatureCut.h + Measure.cpp + Measure.h ) add_library(Surface SHARED ${Surface_SRCS}) diff --git a/src/Mod/Surface/App/Measure.cpp b/src/Mod/Surface/App/Measure.cpp new file mode 100644 index 0000000000..8e2571ac33 --- /dev/null +++ b/src/Mod/Surface/App/Measure.cpp @@ -0,0 +1,37 @@ +/*************************************************************************** + * Copyright (c) 2025 Wandererfan * + * * + * This file is part of FreeCAD. * + * * + * FreeCAD is free software: you can redistribute it and/or modify it * + * under the terms of the GNU Lesser General Public License as * + * published by the Free Software Foundation, either version 2.1 of the * + * License, or (at your option) any later version. * + * * + * FreeCAD is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with FreeCAD. If not, see * + * . * + * * + **************************************************************************/ + +//! a class for establishing our connection with the unified measurement facility +//! we are treating surfaces like Part objects for now + + +#include +#include +#include "Base/Console.h" +#include "Measure.h" + + +void Surface::Measure::initialize() +{ + const App::MeasureHandler& handler = App::MeasureManager::getMeasureHandler("Part"); + + App::MeasureManager::addMeasureHandler("Surface", handler.typeCb); +} diff --git a/src/Mod/Surface/App/Measure.h b/src/Mod/Surface/App/Measure.h new file mode 100644 index 0000000000..bd6122b840 --- /dev/null +++ b/src/Mod/Surface/App/Measure.h @@ -0,0 +1,43 @@ +/*************************************************************************** + * Copyright (c) 2025 Wandererfan * + * * + * This file is part of FreeCAD. * + * * + * FreeCAD is free software: you can redistribute it and/or modify it * + * under the terms of the GNU Lesser General Public License as * + * published by the Free Software Foundation, either version 2.1 of the * + * License, or (at your option) any later version. * + * * + * FreeCAD is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with FreeCAD. If not, see * + * . * + * * + **************************************************************************/ + +//! a class for establishing our connection with the unified measurement facility + +#ifndef SURFACE_MEASURE_H +#define SURFACE_MEASURE_H + +#include + + +namespace Surface +{ + + +class SurfaceExport Measure +{ +public: + static void initialize(); +}; + + +} // namespace Surface + +#endif