From c7e48869b62b624616be90fd9f9ac73cb9976dd7 Mon Sep 17 00:00:00 2001 From: Uwe Date: Sun, 20 Feb 2022 21:23:05 +0100 Subject: [PATCH] [PD] Body and utils: remove unused includes --- src/Mod/PartDesign/App/Body.cpp | 25 +-- src/Mod/PartDesign/App/Body.h | 3 - src/Mod/PartDesign/App/BodyPyImp.cpp | 196 +++++++++--------- src/Mod/PartDesign/Gui/Utils.cpp | 23 +- src/Mod/PartDesign/Gui/ViewProviderAddSub.cpp | 19 +- src/Mod/PartDesign/Gui/ViewProviderBase.cpp | 195 +++++++++-------- src/Mod/PartDesign/Gui/ViewProviderBody.cpp | 6 +- 7 files changed, 212 insertions(+), 255 deletions(-) diff --git a/src/Mod/PartDesign/App/Body.cpp b/src/Mod/PartDesign/App/Body.cpp index 8f6cb34c1f..32413e97b3 100644 --- a/src/Mod/PartDesign/App/Body.cpp +++ b/src/Mod/PartDesign/App/Body.cpp @@ -23,31 +23,16 @@ #include "PreCompiled.h" -#ifndef _PreComp_ -#endif - -#include -#include - -#include #include #include - -#include -#include - - -#include "Feature.h" -#include "FeatureSketchBased.h" -#include "FeatureTransformed.h" -#include "DatumPoint.h" -#include "DatumLine.h" -#include "DatumPlane.h" -#include "ShapeBinder.h" +#include #include "Body.h" -#include "FeatureBase.h" #include "BodyPy.h" +#include "FeatureBase.h" +#include "FeatureSketchBased.h" +#include "FeatureTransformed.h" +#include "ShapeBinder.h" using namespace PartDesign; diff --git a/src/Mod/PartDesign/App/Body.h b/src/Mod/PartDesign/App/Body.h index d26852987d..b9a87facf5 100644 --- a/src/Mod/PartDesign/App/Body.h +++ b/src/Mod/PartDesign/App/Body.h @@ -24,11 +24,8 @@ #ifndef PARTDESIGN_Body_H #define PARTDESIGN_Body_H -#include #include -#include - namespace App { class Origin; } diff --git a/src/Mod/PartDesign/App/BodyPyImp.cpp b/src/Mod/PartDesign/App/BodyPyImp.cpp index 89f6a08320..7b2c5b0f42 100644 --- a/src/Mod/PartDesign/App/BodyPyImp.cpp +++ b/src/Mod/PartDesign/App/BodyPyImp.cpp @@ -1,101 +1,95 @@ -/*************************************************************************** - * Copyright (c) 2010 Juergen Riegel * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library 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 Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - - -#include "PreCompiled.h" - -#ifndef _PreComp_ -#include -#endif - - -#include "Mod/Part/App/Part2DObject.h" -#include "Mod/PartDesign/App/Body.h" -#include "Mod/PartDesign/App/Feature.h" - -// inclusion of the generated files (generated out of ItemPy.xml) -#include "BodyPy.h" -#include "BodyPy.cpp" - -using namespace PartDesign; - -// returns a string which represents the object e.g. when printed in python -std::string BodyPy::representation(void) const -{ - return std::string(""); -} - - - -PyObject *BodyPy::getCustomAttributes(const char* /*attr*/) const -{ - return 0; -} - -int BodyPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/) -{ - return 0; -} - -PyObject* BodyPy::insertObject(PyObject *args) -{ - PyObject* featurePy; - PyObject* targetPy; - PyObject* afterPy = Py_False; - if (!PyArg_ParseTuple(args, "O!O|O!", &(App::DocumentObjectPy::Type), &featurePy, - &targetPy, &PyBool_Type, &afterPy)) { - return 0; - } - - App::DocumentObject* feature = static_cast(featurePy)->getDocumentObjectPtr(); - App::DocumentObject* target = nullptr; - if (PyObject_TypeCheck(targetPy, &(App::DocumentObjectPy::Type))) { - target = static_cast(targetPy)->getDocumentObjectPtr(); - } - - if (!Body::isAllowed(feature)) { - PyErr_SetString(PyExc_SystemError, "Only PartDesign features, datum features and sketches can be inserted into a Body"); - return 0; - } - - bool after = PyObject_IsTrue(afterPy) ? true : false; - Body* body = this->getBodyPtr(); - - try { - body->insertObject(feature, target, after); - } - catch (Base::Exception& e) { - PyErr_SetString(PyExc_SystemError, e.what()); - return 0; - } - - Py_Return; -} - -Py::Object BodyPy::getVisibleFeature() const { - for(auto obj : getBodyPtr()->Group.getValues()) { - if(obj->Visibility.getValue() && obj->isDerivedFrom(PartDesign::Feature::getClassTypeId())) - return Py::Object(obj->getPyObject(),true); - } - return Py::Object(); -} - +/*************************************************************************** + * Copyright (c) 2010 Juergen Riegel * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + * This library 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 Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + + +#include "PreCompiled.h" + +#include "Mod/PartDesign/App/Body.h" +#include "Mod/PartDesign/App/Feature.h" + +// inclusion of the generated files (generated out of ItemPy.xml) +#include "BodyPy.h" +#include "BodyPy.cpp" + +using namespace PartDesign; + +// returns a string which represents the object e.g. when printed in python +std::string BodyPy::representation(void) const +{ + return std::string(""); +} + + + +PyObject *BodyPy::getCustomAttributes(const char* /*attr*/) const +{ + return 0; +} + +int BodyPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/) +{ + return 0; +} + +PyObject* BodyPy::insertObject(PyObject *args) +{ + PyObject* featurePy; + PyObject* targetPy; + PyObject* afterPy = Py_False; + if (!PyArg_ParseTuple(args, "O!O|O!", &(App::DocumentObjectPy::Type), &featurePy, + &targetPy, &PyBool_Type, &afterPy)) { + return 0; + } + + App::DocumentObject* feature = static_cast(featurePy)->getDocumentObjectPtr(); + App::DocumentObject* target = nullptr; + if (PyObject_TypeCheck(targetPy, &(App::DocumentObjectPy::Type))) { + target = static_cast(targetPy)->getDocumentObjectPtr(); + } + + if (!Body::isAllowed(feature)) { + PyErr_SetString(PyExc_SystemError, "Only PartDesign features, datum features and sketches can be inserted into a Body"); + return 0; + } + + bool after = PyObject_IsTrue(afterPy) ? true : false; + Body* body = this->getBodyPtr(); + + try { + body->insertObject(feature, target, after); + } + catch (Base::Exception& e) { + PyErr_SetString(PyExc_SystemError, e.what()); + return 0; + } + + Py_Return; +} + +Py::Object BodyPy::getVisibleFeature() const { + for(auto obj : getBodyPtr()->Group.getValues()) { + if(obj->Visibility.getValue() && obj->isDerivedFrom(PartDesign::Feature::getClassTypeId())) + return Py::Object(obj->getPyObject(),true); + } + return Py::Object(); +} + diff --git a/src/Mod/PartDesign/Gui/Utils.cpp b/src/Mod/PartDesign/Gui/Utils.cpp index d35838de94..b8f926de4b 100644 --- a/src/Mod/PartDesign/Gui/Utils.cpp +++ b/src/Mod/PartDesign/Gui/Utils.cpp @@ -24,35 +24,26 @@ #ifndef _PreComp_ #include -# include # include +# include #endif -#include -#include #include #include -#include +#include #include -#include #include #include #include -#include - +#include +#include +#include #include -#include -#include -#include -#include -#include -#include - -#include "ReferenceSelection.h" #include "Utils.h" -#include "WorkflowManager.h" #include "DlgActiveBody.h" +#include "ReferenceSelection.h" +#include "WorkflowManager.h" FC_LOG_LEVEL_INIT("PartDesignGui",true,true) diff --git a/src/Mod/PartDesign/Gui/ViewProviderAddSub.cpp b/src/Mod/PartDesign/Gui/ViewProviderAddSub.cpp index 016f12b480..4b971c4f26 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderAddSub.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderAddSub.cpp @@ -31,26 +31,21 @@ # include # include # include +# include # include # include -# include +# include # include # include -# include #endif -#include "ViewProviderAddSub.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include "ViewProviderAddSub.h" using namespace PartDesignGui; diff --git a/src/Mod/PartDesign/Gui/ViewProviderBase.cpp b/src/Mod/PartDesign/Gui/ViewProviderBase.cpp index 20f51a2ab9..d8fb296fba 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderBase.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderBase.cpp @@ -1,99 +1,96 @@ -/*************************************************************************** - * Copyright (c) 2017 Stefan Tröger * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library 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 Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - - -#include "PreCompiled.h" - -#ifndef _PreComp_ -#endif - -#include -#include "ViewProviderBase.h" -#include -#include - - -using namespace PartDesignGui; - -PROPERTY_SOURCE(PartDesignGui::ViewProviderBase,PartDesignGui::ViewProvider) - -ViewProviderBase::ViewProviderBase() -{ - sPixmap = "PartDesign_BaseFeature.svg"; -} - -ViewProviderBase::~ViewProviderBase() -{ - -} - -bool ViewProviderBase::doubleClicked(void) -{ - // If the Placement is mutable then open the transform panel. - // If the Placement can't be modified then just do nothing on double-click. - PartDesign::FeatureBase* base = static_cast(getObject()); - if (!base->Placement.testStatus(App::Property::Immutable) && - !base->Placement.testStatus(App::Property::ReadOnly) && - !base->Placement.testStatus(App::Property::Hidden)) { - - try { - std::string Msg("Edit "); - Msg += base->Label.getValue(); - Gui::Command::openCommand(Msg.c_str()); - FCMD_SET_EDIT(base); - } - catch (const Base::Exception&) { - Gui::Command::abortCommand(); - } - return true; - } - - return false; -} - -void ViewProviderBase::setupContextMenu(QMenu* menu, QObject* receiver, const char* member) -{ - // If the Placement is mutable then show the context-menu of the base class. - PartDesign::FeatureBase* base = static_cast(getObject()); - if (!base->Placement.testStatus(App::Property::Immutable) && - !base->Placement.testStatus(App::Property::ReadOnly) && - !base->Placement.testStatus(App::Property::Hidden)) { - PartDesignGui::ViewProvider::setupContextMenu(menu, receiver, member); - } -} - -bool ViewProviderBase::setEdit(int ModNum) -{ - PartDesign::FeatureBase* base = static_cast(getObject()); - if (!base->Placement.testStatus(App::Property::Immutable) && - !base->Placement.testStatus(App::Property::ReadOnly) && - !base->Placement.testStatus(App::Property::Hidden)) { - return PartGui::ViewProviderPart::setEdit(ModNum); - } - - return false; -} - -void ViewProviderBase::unsetEdit(int ModNum) -{ - PartGui::ViewProviderPart::unsetEdit(ModNum); -} +/*************************************************************************** + * Copyright (c) 2017 Stefan Tröger * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + * This library 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 Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + + +#include "PreCompiled.h" + +#include +#include + +#include "ViewProviderBase.h" + + +using namespace PartDesignGui; + +PROPERTY_SOURCE(PartDesignGui::ViewProviderBase,PartDesignGui::ViewProvider) + +ViewProviderBase::ViewProviderBase() +{ + sPixmap = "PartDesign_BaseFeature.svg"; +} + +ViewProviderBase::~ViewProviderBase() +{ + +} + +bool ViewProviderBase::doubleClicked(void) +{ + // If the Placement is mutable then open the transform panel. + // If the Placement can't be modified then just do nothing on double-click. + PartDesign::FeatureBase* base = static_cast(getObject()); + if (!base->Placement.testStatus(App::Property::Immutable) && + !base->Placement.testStatus(App::Property::ReadOnly) && + !base->Placement.testStatus(App::Property::Hidden)) { + + try { + std::string Msg("Edit "); + Msg += base->Label.getValue(); + Gui::Command::openCommand(Msg.c_str()); + FCMD_SET_EDIT(base); + } + catch (const Base::Exception&) { + Gui::Command::abortCommand(); + } + return true; + } + + return false; +} + +void ViewProviderBase::setupContextMenu(QMenu* menu, QObject* receiver, const char* member) +{ + // If the Placement is mutable then show the context-menu of the base class. + PartDesign::FeatureBase* base = static_cast(getObject()); + if (!base->Placement.testStatus(App::Property::Immutable) && + !base->Placement.testStatus(App::Property::ReadOnly) && + !base->Placement.testStatus(App::Property::Hidden)) { + PartDesignGui::ViewProvider::setupContextMenu(menu, receiver, member); + } +} + +bool ViewProviderBase::setEdit(int ModNum) +{ + PartDesign::FeatureBase* base = static_cast(getObject()); + if (!base->Placement.testStatus(App::Property::Immutable) && + !base->Placement.testStatus(App::Property::ReadOnly) && + !base->Placement.testStatus(App::Property::Hidden)) { + return PartGui::ViewProviderPart::setEdit(ModNum); + } + + return false; +} + +void ViewProviderBase::unsetEdit(int ModNum) +{ + PartGui::ViewProviderPart::unsetEdit(ModNum); +} diff --git a/src/Mod/PartDesign/Gui/ViewProviderBody.cpp b/src/Mod/PartDesign/Gui/ViewProviderBody.cpp index 52b51611db..7833de6dd5 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderBody.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderBody.cpp @@ -24,22 +24,20 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include # include # include # include # include #endif +#include +#include #include #include #include #include #include #include -#include -#include -#include #include #include #include