[Sketcher] Add handlers for unified measurement facility

This commit is contained in:
hlorus
2024-01-14 21:32:57 +01:00
committed by WandererFan
parent 6318586353
commit 309e1c4155
4 changed files with 88 additions and 1 deletions

View File

@@ -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);

View File

@@ -121,6 +121,8 @@ SET(SketchModule_SRCS
AppSketcherPy.cpp
PreCompiled.cpp
PreCompiled.h
Measure.cpp
Measure.h
)
SOURCE_GROUP("Module" FILES ${SketchModule_SRCS})

View File

@@ -0,0 +1,38 @@
/***************************************************************************
* Copyright (c) 2023 Wandererfan <wandererfan@gmail.com> *
* *
* This file is part of FreeCAD. *
* *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
**************************************************************************/
//! a class for establishing our connection with the unified measurement facility
//! we are treating sketches like Part objects for now
#include "PreCompiled.h"
#include <App/Application.h>
#include <App/MeasureManager.h>
#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);
}

View File

@@ -0,0 +1,43 @@
/***************************************************************************
* Copyright (c) 2023 Wandererfan <wandererfan@gmail.com> *
* *
* This file is part of FreeCAD. *
* *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
**************************************************************************/
//! a class for establishing our connection with the unified measurement facility
#ifndef SKETCHER_MEASURE_H
#define SKETCHER_MEASURE_H
#include <Mod/Sketcher/SketcherGlobal.h>
namespace Sketcher
{
class SketcherExport Measure
{
public:
static void initialize();
};
} // namespace Sketcher
#endif