Gui: Rework TaskCSysDragger into new Transform Dialog
This commit refactor ViewProviderDragger and TaskCSysDragger to be more modern and to support selecting TransformOrigin.
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
#include <Base/ExceptionFactory.h>
|
||||
#include <Base/Interpreter.h>
|
||||
#include <Base/Parameter.h>
|
||||
#include <Base/ServiceProvider.h>
|
||||
#include <Base/PrecisionPy.h>
|
||||
|
||||
#include "ArcOfCirclePy.h"
|
||||
@@ -187,8 +188,12 @@
|
||||
|
||||
#include <OCAF/ImportExportSettings.h>
|
||||
#include "MeasureClient.h"
|
||||
|
||||
#include <FuzzyHelper.h>
|
||||
|
||||
#include <App/Services.h>
|
||||
#include <Services.h>
|
||||
|
||||
namespace Part {
|
||||
extern PyObject* initModule();
|
||||
}
|
||||
@@ -572,7 +577,10 @@ PyMOD_INIT_FUNC(Part)
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part/Boolean");
|
||||
|
||||
Part::FuzzyHelper::setBooleanFuzzy(hGrp->GetFloat("BooleanFuzzy",10.0));
|
||||
|
||||
|
||||
Base::registerServiceImplementation<App::SubObjectPlacementProvider>(new AttacherSubObjectPlacement);
|
||||
Base::registerServiceImplementation<App::CenterOfMassProvider>(new PartCenterOfMass);
|
||||
|
||||
PyMOD_Return(partModule);
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
@@ -553,6 +553,8 @@ SET(Part_SRCS
|
||||
PreCompiled.h
|
||||
ProgressIndicator.cpp
|
||||
ProgressIndicator.h
|
||||
Services.cpp
|
||||
Services.h
|
||||
TopoShape.cpp
|
||||
TopoShape.h
|
||||
TopoShapeCache.cpp
|
||||
|
||||
52
src/Mod/Part/App/Services.cpp
Normal file
52
src/Mod/Part/App/Services.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
/****************************************************************************
|
||||
* *
|
||||
* Copyright (c) 2024 Kacper Donat <kacper@kadet.net> *
|
||||
* *
|
||||
* This file is part of FreeCAD. *
|
||||
* *
|
||||
* FreeCAD is free software: you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 2.1 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* FreeCAD is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with FreeCAD. If not, see *
|
||||
* <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "Services.h"
|
||||
|
||||
AttacherSubObjectPlacement::AttacherSubObjectPlacement()
|
||||
: attacher(std::make_unique<Attacher::AttachEngine3D>())
|
||||
{
|
||||
attacher->setUp({}, Attacher::mmMidpoint);
|
||||
}
|
||||
|
||||
Base::Placement AttacherSubObjectPlacement::calculate(App::SubObjectT object,
|
||||
Base::Placement basePlacement) const
|
||||
{
|
||||
attacher->setReferences({object});
|
||||
return basePlacement.inverse() * attacher->calculateAttachedPlacement(basePlacement);
|
||||
}
|
||||
|
||||
std::optional<Base::Vector3d> PartCenterOfMass::ofDocumentObject(App::DocumentObject* object) const
|
||||
{
|
||||
if (const auto feature = dynamic_cast<Part::Feature*>(object)) {
|
||||
const auto shape = feature->Shape.getShape();
|
||||
|
||||
if (const auto cog = shape.centerOfGravity()) {
|
||||
const Base::Placement comPlacement { *cog, Base::Rotation { } };
|
||||
|
||||
return (feature->Placement.getValue().inverse() * comPlacement).getPosition();
|
||||
}
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
47
src/Mod/Part/App/Services.h
Normal file
47
src/Mod/Part/App/Services.h
Normal file
@@ -0,0 +1,47 @@
|
||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
/****************************************************************************
|
||||
* *
|
||||
* Copyright (c) 2024 Kacper Donat <kacper@kadet.net> *
|
||||
* *
|
||||
* This file is part of FreeCAD. *
|
||||
* *
|
||||
* FreeCAD is free software: you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 2.1 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* FreeCAD is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with FreeCAD. If not, see *
|
||||
* <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef PART_SERVICES_H
|
||||
#define PART_SERVICES_H
|
||||
|
||||
#include <Attacher.h>
|
||||
#include <App/Services.h>
|
||||
|
||||
class AttacherSubObjectPlacement final: public App::SubObjectPlacementProvider
|
||||
{
|
||||
public:
|
||||
AttacherSubObjectPlacement();
|
||||
|
||||
Base::Placement calculate(App::SubObjectT object, Base::Placement basePlacement) const override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<Attacher::AttachEngine3D> attacher;
|
||||
};
|
||||
|
||||
class PartCenterOfMass final: public App::CenterOfMassProvider
|
||||
{
|
||||
public:
|
||||
std::optional<Base::Vector3d> ofDocumentObject(App::DocumentObject* object) const override;
|
||||
};
|
||||
|
||||
#endif // PART_SERVICES_H
|
||||
Reference in New Issue
Block a user