From 309e1c4155dd923587e850fe233bbabc0e379860 Mon Sep 17 00:00:00 2001 From: hlorus Date: Sun, 14 Jan 2024 21:32:57 +0100 Subject: [PATCH] [Sketcher] Add handlers for unified measurement facility --- src/Mod/Sketcher/App/AppSketcher.cpp | 6 +++- src/Mod/Sketcher/App/CMakeLists.txt | 2 ++ src/Mod/Sketcher/App/Measure.cpp | 38 ++++++++++++++++++++++++ src/Mod/Sketcher/App/Measure.h | 43 ++++++++++++++++++++++++++++ 4 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 src/Mod/Sketcher/App/Measure.cpp create mode 100644 src/Mod/Sketcher/App/Measure.h diff --git a/src/Mod/Sketcher/App/AppSketcher.cpp b/src/Mod/Sketcher/App/AppSketcher.cpp index a1190b4c25..eba2a200e6 100644 --- a/src/Mod/Sketcher/App/AppSketcher.cpp +++ b/src/Mod/Sketcher/App/AppSketcher.cpp @@ -41,7 +41,7 @@ #include "SketchObjectSF.h" #include "SketchPy.h" #include "SolverGeometryExtension.h" - +#include "Measure.h" namespace Sketcher { @@ -95,6 +95,10 @@ PyMOD_INIT_FUNC(Sketcher) Sketcher::Constraint ::init(); Sketcher::PropertyConstraintList ::init(); + // connect to unified measurement facility + Sketcher::Measure ::initialize(); + + Base::Console().Log("Loading Sketcher module... done\n"); PyMOD_Return(sketcherModule); diff --git a/src/Mod/Sketcher/App/CMakeLists.txt b/src/Mod/Sketcher/App/CMakeLists.txt index f3ee9500af..f563f04790 100644 --- a/src/Mod/Sketcher/App/CMakeLists.txt +++ b/src/Mod/Sketcher/App/CMakeLists.txt @@ -121,6 +121,8 @@ SET(SketchModule_SRCS AppSketcherPy.cpp PreCompiled.cpp PreCompiled.h + Measure.cpp + Measure.h ) SOURCE_GROUP("Module" FILES ${SketchModule_SRCS}) diff --git a/src/Mod/Sketcher/App/Measure.cpp b/src/Mod/Sketcher/App/Measure.cpp new file mode 100644 index 0000000000..f57e52f8ec --- /dev/null +++ b/src/Mod/Sketcher/App/Measure.cpp @@ -0,0 +1,38 @@ +/*************************************************************************** + * Copyright (c) 2023 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 sketches like Part objects for now + +#include "PreCompiled.h" + +#include +#include +#include "Base/Console.h" +#include "Measure.h" + + +void Sketcher::Measure::initialize() +{ + const App::MeasureHandler& handler = App::MeasureManager::getMeasureHandler("Part"); + + App::MeasureManager::addMeasureHandler("Sketcher", handler.typeCb); +} diff --git a/src/Mod/Sketcher/App/Measure.h b/src/Mod/Sketcher/App/Measure.h new file mode 100644 index 0000000000..3058c79fe4 --- /dev/null +++ b/src/Mod/Sketcher/App/Measure.h @@ -0,0 +1,43 @@ +/*************************************************************************** + * Copyright (c) 2023 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 SKETCHER_MEASURE_H +#define SKETCHER_MEASURE_H + +#include + + +namespace Sketcher +{ + + +class SketcherExport Measure +{ +public: + static void initialize(); +}; + + +} // namespace Sketcher + +#endif