From 6c0f42bb15ed5293e64cc86962e4d3c09df56d1b Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 18 Jun 2024 18:01:22 +0200 Subject: [PATCH 1/4] Fem: Fix copyright notices Do not clutter copyright notices with changes made to a file. That's the task of the VCS --- src/Mod/Fem/App/AppFem.cpp | 3 -- src/Mod/Fem/App/FemSetElementNodesObject.cpp | 27 ++++++++--------- src/Mod/Fem/App/FemSetElementNodesObject.h | 27 ++++++++--------- src/Mod/Fem/Gui/AppFemGui.cpp | 3 -- src/Mod/Fem/Gui/Command.cpp | 6 ---- src/Mod/Fem/Gui/TaskCreateElementSet.cpp | 28 ++++++++---------- src/Mod/Fem/Gui/TaskCreateElementSet.h | 27 ++++++++--------- src/Mod/Fem/Gui/TaskDlgCreateElementSet.cpp | 29 +++++++++---------- src/Mod/Fem/Gui/TaskDlgCreateElementSet.h | 26 ++++++++--------- .../Fem/Gui/ViewProviderSetElementNodes.cpp | 26 ++++++++--------- src/Mod/Fem/Gui/ViewProviderSetElementNodes.h | 26 ++++++++--------- src/Mod/Fem/Gui/Workbench.cpp | 4 --- 12 files changed, 97 insertions(+), 135 deletions(-) diff --git a/src/Mod/Fem/App/AppFem.cpp b/src/Mod/Fem/App/AppFem.cpp index 54654aea34..81cf2e84b7 100644 --- a/src/Mod/Fem/App/AppFem.cpp +++ b/src/Mod/Fem/App/AppFem.cpp @@ -1,8 +1,5 @@ /*************************************************************************** * Copyright (c) 2023 Peter McB * - * additional statement(s) for element sets * - * * - * added to: AppFem.cpp * * Copyright (c) 2013 Jürgen Riegel (FreeCAD@juergen-riegel.net) * * * * This file is part of the FreeCAD CAx development system. * diff --git a/src/Mod/Fem/App/FemSetElementNodesObject.cpp b/src/Mod/Fem/App/FemSetElementNodesObject.cpp index 52f2925172..60a659d159 100644 --- a/src/Mod/Fem/App/FemSetElementNodesObject.cpp +++ b/src/Mod/Fem/App/FemSetElementNodesObject.cpp @@ -1,25 +1,23 @@ /*************************************************************************** * Copyright (c) 2023 Peter McB * * * - * based on: FemSetNodesObject.cpp * * Copyright (c) 2013 Jürgen Riegel (FreeCAD@juergen-riegel.net) * * * - * This file is part of the FreeCAD CAx development system. * + * This file is part of FreeCAD. * * * - * 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. * + * 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. * * * - * 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. * + * 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 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 * + * You should have received a copy of the GNU Lesser General Public * + * License along with FreeCAD. If not, see * + * . * * * ***************************************************************************/ @@ -35,7 +33,6 @@ using namespace App; PROPERTY_SOURCE(Fem::FemSetElementNodesObject, Fem::FemSetObject) - FemSetElementNodesObject::FemSetElementNodesObject() { ADD_PROPERTY_TYPE(Elements, diff --git a/src/Mod/Fem/App/FemSetElementNodesObject.h b/src/Mod/Fem/App/FemSetElementNodesObject.h index ed79ccbb99..268f322fd2 100644 --- a/src/Mod/Fem/App/FemSetElementNodesObject.h +++ b/src/Mod/Fem/App/FemSetElementNodesObject.h @@ -1,25 +1,22 @@ /*************************************************************************** * Copyright (c) 2023 Peter McB * - * * - * based on: FemSetNodesObject.h * * Copyright (c) 2013 Jürgen Riegel (FreeCAD@juergen-riegel.net) * * * - * This file is part of the FreeCAD CAx development system. * + * This file is part of FreeCAD. * * * - * 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. * + * 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. * * * - * 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. * + * 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 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 * + * You should have received a copy of the GNU Lesser General Public * + * License along with FreeCAD. If not, see * + * . * * * ***************************************************************************/ diff --git a/src/Mod/Fem/Gui/AppFemGui.cpp b/src/Mod/Fem/Gui/AppFemGui.cpp index 4acb5219c4..ffe08198d4 100644 --- a/src/Mod/Fem/Gui/AppFemGui.cpp +++ b/src/Mod/Fem/Gui/AppFemGui.cpp @@ -1,8 +1,5 @@ /*************************************************************************** * Copyright (c) 2023 Peter McB * - * additional statement(s) for element sets * - * * - * added to: AppFemGui.cpp * * Copyright (c) 2008 Jürgen Riegel * * * * This file is part of the FreeCAD CAx development system. * diff --git a/src/Mod/Fem/Gui/Command.cpp b/src/Mod/Fem/Gui/Command.cpp index ad1557b81b..ab59eb9035 100644 --- a/src/Mod/Fem/Gui/Command.cpp +++ b/src/Mod/Fem/Gui/Command.cpp @@ -1,9 +1,5 @@ /*************************************************************************** * Copyright (c) 2022 Peter McB * - * added erase elements function * - * * - * added to: Command.cpp * - * * * Copyright (c) 2008 Jürgen Riegel * * * * This file is part of the FreeCAD CAx development system. * @@ -1254,7 +1250,6 @@ bool CmdFemCreateNodesSet::isActive() std::string Fem::FemSetElementNodesObject::elementsName; std::string Fem::FemSetElementNodesObject::uniqueElementsName; - DEF_STD_CMD_A(CmdFemDefineElementsSet); void DefineElementsCallback(void* ud, SoEventCallback* n) @@ -1427,7 +1422,6 @@ void CmdFemCreateElementsSet::activated(int) Fem::FemSetElementNodesObject::uniqueElementsName = Command::getUniqueObjectName(Fem::FemSetElementNodesObject::elementsName.c_str()); - openCommand(QT_TRANSLATE_NOOP("Command", "Create Elements set")); doCommand(Doc, "App.activeDocument().addObject('Fem::FemSetElementNodesObject','%s')", diff --git a/src/Mod/Fem/Gui/TaskCreateElementSet.cpp b/src/Mod/Fem/Gui/TaskCreateElementSet.cpp index 566d58c77f..b3d11cd723 100644 --- a/src/Mod/Fem/Gui/TaskCreateElementSet.cpp +++ b/src/Mod/Fem/Gui/TaskCreateElementSet.cpp @@ -1,26 +1,22 @@ /*************************************************************************** * Copyright (c) 2023 Peter McB * - * implementation of the erase elements function * - * * - * loosely based on: TaskCreateNodeSet.cpp * * Copyright (c) 2013 Jürgen Riegel (FreeCAD@juergen-riegel.net) * * * - * This file is part of the FreeCAD CAx development system. * + * This file is part of FreeCAD. * * * - * 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. * + * 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. * * * - * 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. * + * 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 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 * + * You should have received a copy of the GNU Lesser General Public * + * License along with FreeCAD. If not, see * + * . * * * ***************************************************************************/ diff --git a/src/Mod/Fem/Gui/TaskCreateElementSet.h b/src/Mod/Fem/Gui/TaskCreateElementSet.h index 6ffd875b3c..97a76574c1 100644 --- a/src/Mod/Fem/Gui/TaskCreateElementSet.h +++ b/src/Mod/Fem/Gui/TaskCreateElementSet.h @@ -1,25 +1,22 @@ /*************************************************************************** * Copyright (c) 2023 Peter McB * - * * - * based on: TaskCreateNodeSet.h * * Copyright (c) 2013 Jürgen Riegel (FreeCAD@juergen-riegel.net) * * * - * This file is part of the FreeCAD CAx development system. * + * This file is part of FreeCAD. * * * - * 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. * + * 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. * * * - * 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. * + * 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 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 * + * You should have received a copy of the GNU Lesser General Public * + * License along with FreeCAD. If not, see * + * . * * * ***************************************************************************/ diff --git a/src/Mod/Fem/Gui/TaskDlgCreateElementSet.cpp b/src/Mod/Fem/Gui/TaskDlgCreateElementSet.cpp index a987486d93..bbc74ea98b 100644 --- a/src/Mod/Fem/Gui/TaskDlgCreateElementSet.cpp +++ b/src/Mod/Fem/Gui/TaskDlgCreateElementSet.cpp @@ -1,30 +1,27 @@ /*************************************************************************** * Copyright (c) 2023 Peter McB * * * - * based on: TaskDlgCreateNodeSet.cpp * * Copyright (c) 2013 Jürgen Riegel (FreeCAD@juergen-riegel.net) * * * - * This file is part of the FreeCAD CAx development system. * + * This file is part of FreeCAD. * * * - * 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. * + * 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. * * * - * 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. * + * 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 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 * + * You should have received a copy of the GNU Lesser General Public * + * License along with FreeCAD. If not, see * + * . * * * ***************************************************************************/ + #include "PreCompiled.h" - - #include #include #include diff --git a/src/Mod/Fem/Gui/TaskDlgCreateElementSet.h b/src/Mod/Fem/Gui/TaskDlgCreateElementSet.h index dc0b96767b..a512c66b67 100644 --- a/src/Mod/Fem/Gui/TaskDlgCreateElementSet.h +++ b/src/Mod/Fem/Gui/TaskDlgCreateElementSet.h @@ -1,25 +1,23 @@ /*************************************************************************** * Copyright (c) 2023 Peter McB * * * - * based on: FemSetNodesObject.h * * Copyright (c) 2013 Jürgen Riegel (FreeCAD@juergen-riegel.net) * * * - * This file is part of the FreeCAD CAx development system. * + * This file is part of FreeCAD. * * * - * 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. * + * 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. * * * - * 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. * + * 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 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 * + * You should have received a copy of the GNU Lesser General Public * + * License along with FreeCAD. If not, see * + * . * * * ***************************************************************************/ diff --git a/src/Mod/Fem/Gui/ViewProviderSetElementNodes.cpp b/src/Mod/Fem/Gui/ViewProviderSetElementNodes.cpp index 87d26d5297..d034fd122a 100644 --- a/src/Mod/Fem/Gui/ViewProviderSetElementNodes.cpp +++ b/src/Mod/Fem/Gui/ViewProviderSetElementNodes.cpp @@ -1,25 +1,23 @@ /*************************************************************************** * Copyright (c) 2023 Peter McB * * * - * based on: ViewProviderSetNodes.cpp * * Copyright (c) 2013 Jürgen Riegel (FreeCAD@juergen-riegel.net) * * * - * This file is part of the FreeCAD CAx development system. * + * This file is part of FreeCAD. * * * - * 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. * + * 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. * * * - * 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. * + * 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 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 * + * You should have received a copy of the GNU Lesser General Public * + * License along with FreeCAD. If not, see * + * . * * * ***************************************************************************/ diff --git a/src/Mod/Fem/Gui/ViewProviderSetElementNodes.h b/src/Mod/Fem/Gui/ViewProviderSetElementNodes.h index f9971d2b8a..46a173fde9 100644 --- a/src/Mod/Fem/Gui/ViewProviderSetElementNodes.h +++ b/src/Mod/Fem/Gui/ViewProviderSetElementNodes.h @@ -1,25 +1,23 @@ /*************************************************************************** * Copyright (c) 2023 Peter McB * * * - * based on: ViewProviderSetNodes.h * * Copyright (c) 2013 Jürgen Riegel (FreeCAD@juergen-riegel.net) * * * - * This file is part of the FreeCAD CAx development system. * + * This file is part of FreeCAD. * * * - * 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. * + * 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. * * * - * 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. * + * 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 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 * + * You should have received a copy of the GNU Lesser General Public * + * License along with FreeCAD. If not, see * + * . * * * ***************************************************************************/ diff --git a/src/Mod/Fem/Gui/Workbench.cpp b/src/Mod/Fem/Gui/Workbench.cpp index 394a38f0fe..2f2600013d 100644 --- a/src/Mod/Fem/Gui/Workbench.cpp +++ b/src/Mod/Fem/Gui/Workbench.cpp @@ -1,9 +1,5 @@ /*************************************************************************** * Copyright (c) 2023 Peter McB * - * additional statement(s) for element sets: * - * added entry to Gui::MenuItem* mesh * - * * - * added to: Workbench.cpp * Copyright (c) 2008 Werner Mayer * * * * This file is part of the FreeCAD CAx development system. * From 47a9ec8481ed2e745b83d4e86e1559b793221b89 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 18 Jun 2024 18:14:10 +0200 Subject: [PATCH 2/4] FEM: Fix linking errors The static members of FemSetElementNodesObject are not defined in Fem but FemGui which the MSVC compiler doesn't like. Furthermore it's a code smell to make them public and static and they are not even used by the class itself. --- src/Mod/Fem/App/FemSetElementNodesObject.h | 6 ++++-- src/Mod/Fem/Gui/Command.cpp | 15 +++++---------- src/Mod/Fem/Gui/TaskCreateElementSet.cpp | 3 ++- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/Mod/Fem/App/FemSetElementNodesObject.h b/src/Mod/Fem/App/FemSetElementNodesObject.h index 268f322fd2..c016d0eec0 100644 --- a/src/Mod/Fem/App/FemSetElementNodesObject.h +++ b/src/Mod/Fem/App/FemSetElementNodesObject.h @@ -53,8 +53,10 @@ public: } short mustExecute() const override; PyObject* getPyObject() override; - static std::string elementsName; // = "ElementsSet"; - static std::string uniqueElementsName; // "ElementsSet" latest name + static std::string getElementName() + { + return "ElementsSet"; + } }; } // namespace Fem diff --git a/src/Mod/Fem/Gui/Command.cpp b/src/Mod/Fem/Gui/Command.cpp index ab59eb9035..553cb818aa 100644 --- a/src/Mod/Fem/Gui/Command.cpp +++ b/src/Mod/Fem/Gui/Command.cpp @@ -1247,8 +1247,6 @@ bool CmdFemCreateNodesSet::isActive() //=========================================================================== // start of Erase Elements code //=========================================================================== -std::string Fem::FemSetElementNodesObject::elementsName; -std::string Fem::FemSetElementNodesObject::uniqueElementsName; DEF_STD_CMD_A(CmdFemDefineElementsSet); @@ -1418,21 +1416,18 @@ void CmdFemCreateElementsSet::activated(int) Fem::FemMeshObject* MeshObj = static_cast(FemMeshFilter.Result[0][0].getObject()); - Fem::FemSetElementNodesObject::elementsName = "ElementsSet"; - Fem::FemSetElementNodesObject::uniqueElementsName = - Command::getUniqueObjectName(Fem::FemSetElementNodesObject::elementsName.c_str()); + std::string elementsName = Fem::FemSetElementNodesObject::getElementName(); + std::string uniqueElementsName = Command::getUniqueObjectName(elementsName.c_str()); openCommand(QT_TRANSLATE_NOOP("Command", "Create Elements set")); doCommand(Doc, "App.activeDocument().addObject('Fem::FemSetElementNodesObject','%s')", - Fem::FemSetElementNodesObject::uniqueElementsName.c_str()); + uniqueElementsName.c_str()); doCommand(Gui, "App.activeDocument().%s.FemMesh = App.activeDocument().%s", - Fem::FemSetElementNodesObject::uniqueElementsName.c_str(), + uniqueElementsName.c_str(), MeshObj->getNameInDocument()); - doCommand(Gui, - "Gui.activeDocument().setEdit('%s')", - Fem::FemSetElementNodesObject::uniqueElementsName.c_str()); + doCommand(Gui, "Gui.activeDocument().setEdit('%s')", uniqueElementsName.c_str()); } else { QMessageBox::warning( diff --git a/src/Mod/Fem/Gui/TaskCreateElementSet.cpp b/src/Mod/Fem/Gui/TaskCreateElementSet.cpp index b3d11cd723..d41d40c029 100644 --- a/src/Mod/Fem/Gui/TaskCreateElementSet.cpp +++ b/src/Mod/Fem/Gui/TaskCreateElementSet.cpp @@ -541,7 +541,8 @@ void TaskCreateElementSet::Restore(void) objectN.c_str()); Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.recompute()"); } - else if (objectN.find(Fem::FemSetElementNodesObject::elementsName) != std::string::npos) { + else if (objectN.find(Fem::FemSetElementNodesObject::getElementName()) + != std::string::npos) { if (elList > 0) { Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.removeObject(\'%s\')", From b7e0313591f5e2547f00e9435e922978234258ea Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 18 Jun 2024 18:48:14 +0200 Subject: [PATCH 3/4] Fem: Refactor DefineNodesCallback and DefineElementsCallback Refactor the two methods to reduce code duplication. --- src/Mod/Fem/Gui/Command.cpp | 237 ++++++++++++++---------------------- 1 file changed, 89 insertions(+), 148 deletions(-) diff --git a/src/Mod/Fem/Gui/Command.cpp b/src/Mod/Fem/Gui/Command.cpp index 553cb818aa..dde134d9dd 100644 --- a/src/Mod/Fem/Gui/Command.cpp +++ b/src/Mod/Fem/Gui/Command.cpp @@ -69,7 +69,7 @@ using namespace std; //================================================================================================ //================================================================================================ // helpers -bool getConstraintPrerequisits(Fem::FemAnalysis** Analysis) +static bool getConstraintPrerequisits(Fem::FemAnalysis** Analysis) { if (!FemGui::ActiveAnalysisObserver::instance()->hasActiveObject()) { QMessageBox::warning(Gui::getMainWindow(), @@ -85,7 +85,7 @@ bool getConstraintPrerequisits(Fem::FemAnalysis** Analysis) } // OvG: Visibility automation show parts and hide meshes on activation of a constraint -std::string gethideMeshShowPartStr(std::string showConstr = "") +static std::string gethideMeshShowPartStr(std::string showConstr = "") { return "for amesh in App.activeDocument().Objects:\n\ if \"" @@ -99,6 +99,63 @@ std::string gethideMeshShowPartStr(std::string showConstr = "") amesh.ViewObject.Visibility = False\n"; } +static std::string getSelectedNodes(Gui::View3DInventorViewer* view) +{ + Gui::SelectionRole role; + std::vector clPoly = view->getGLPolygon(&role); + if (clPoly.size() < 3) { + return {}; + } + if (clPoly.front() != clPoly.back()) { + clPoly.push_back(clPoly.front()); + } + + SoCamera* cam = view->getSoRenderManager()->getCamera(); + SbViewVolume vv = cam->getViewVolume(); + Gui::ViewVolumeProjection proj(vv); + Base::Polygon2d polygon; + for (auto it : clPoly) { + polygon.Add(Base::Vector2d(it[0], it[1])); + } + + std::vector docObj = + Gui::Selection().getObjectsOfType(Fem::FemMeshObject::getClassTypeId()); + if (docObj.size() != 1) { + return {}; + } + + const SMESHDS_Mesh* data = + static_cast(docObj[0])->FemMesh.getValue().getSMesh()->GetMeshDS(); + + SMDS_NodeIteratorPtr aNodeIter = data->nodesIterator(); + Base::Vector3f pt2d; + std::set IntSet; + + while (aNodeIter->more()) { + const SMDS_MeshNode* aNode = aNodeIter->next(); + Base::Vector3f vec(aNode->X(), aNode->Y(), aNode->Z()); + pt2d = proj(vec); + if (polygon.Contains(Base::Vector2d(pt2d.x, pt2d.y))) { + IntSet.insert(aNode->GetID()); + } + } + + std::stringstream set; + + set << "["; + for (auto it = IntSet.cbegin(); it != IntSet.cend(); ++it) { + if (it == IntSet.begin()) { + set << *it; + } + else { + set << "," << *it; + } + } + set << "]"; + + return set.str(); +} + //================================================================================================ //================================================================================================ @@ -1031,7 +1088,7 @@ bool CmdFemConstraintTransform::isActive() //================================================================================================ DEF_STD_CMD_A(CmdFemDefineNodesSet) -void DefineNodesCallback(void* ud, SoEventCallback* n) +static void DefineNodesCallback(void* ud, SoEventCallback* n) { Fem::FemAnalysis* Analysis; @@ -1048,88 +1105,20 @@ void DefineNodesCallback(void* ud, SoEventCallback* n) view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), DefineNodesCallback, ud); n->setHandled(); - Gui::SelectionRole role; - std::vector clPoly = view->getGLPolygon(&role); - if (clPoly.size() < 3) { - return; + std::string str = getSelectedNodes(view); + if (!str.empty()) { + Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Place robot")); + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.addObject('Fem::FemSetNodesObject','NodeSet')"); + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.ActiveObject.Nodes = %s", + str.c_str()); + Gui::Command::doCommand(Gui::Command::Doc, + "App.activeDocument().%s.addObject(App.activeDocument().NodeSet)", + Analysis->getNameInDocument()); + + Gui::Command::commitCommand(); } - if (clPoly.front() != clPoly.back()) { - clPoly.push_back(clPoly.front()); - } - - SoCamera* cam = view->getSoRenderManager()->getCamera(); - SbViewVolume vv = cam->getViewVolume(); - Gui::ViewVolumeProjection proj(vv); - Base::Polygon2d polygon; - for (auto it : clPoly) { - polygon.Add(Base::Vector2d(it[0], it[1])); - } - - - std::vector docObj = - Gui::Selection().getObjectsOfType(Fem::FemMeshObject::getClassTypeId()); - if (docObj.size() != 1) { - return; - } - - const SMESHDS_Mesh* data = - static_cast(docObj[0])->FemMesh.getValue().getSMesh()->GetMeshDS(); - - SMDS_NodeIteratorPtr aNodeIter = data->nodesIterator(); - Base::Vector3f pt2d; - std::set IntSet; - - while (aNodeIter->more()) { - const SMDS_MeshNode* aNode = aNodeIter->next(); - Base::Vector3f vec(aNode->X(), aNode->Y(), aNode->Z()); - pt2d = proj(vec); - if (polygon.Contains(Base::Vector2d(pt2d.x, pt2d.y))) { - IntSet.insert(aNode->GetID()); - } - } - - std::stringstream set; - - set << "["; - for (std::set::const_iterator it = IntSet.begin(); it != IntSet.end(); ++it) { - if (it == IntSet.begin()) { - set << *it; - } - else { - set << "," << *it; - } - } - set << "]"; - - - Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Place robot")); - Gui::Command::doCommand(Gui::Command::Doc, - "App.ActiveDocument.addObject('Fem::FemSetNodesObject','NodeSet')"); - Gui::Command::doCommand(Gui::Command::Doc, - "App.ActiveDocument.ActiveObject.Nodes = %s", - set.str().c_str()); - Gui::Command::doCommand(Gui::Command::Doc, - "App.activeDocument().%s.addObject(App.activeDocument().NodeSet)", - Analysis->getNameInDocument()); - // Gui::Command::updateActive(); - Gui::Command::commitCommand(); - - // std::vector views = - // view->getViewProvidersOfType(ViewProviderMesh::getClassTypeId()); if (!views.empty()) { - // Gui::Application::Instance->activeDocument()->openCommand(QT_TRANSLATE_NOOP("Command", - // "Cut")); for (std::vector::iterator it = views.begin(); it != - // views.end(); ++it) { - // ViewProviderMesh* that = static_cast(*it); - // if (that->getEditingMode() > -1) { - // that->finishEditing(); - // that->cutMesh(clPoly, *view, clip_inner); - // } - // } - - // Gui::Application::Instance->activeDocument()->commitCommand(); - - // view->render(); - //} } @@ -1250,7 +1239,7 @@ bool CmdFemCreateNodesSet::isActive() DEF_STD_CMD_A(CmdFemDefineElementsSet); -void DefineElementsCallback(void* ud, SoEventCallback* n) +static void DefineElementsCallback(void* ud, SoEventCallback* n) { Fem::FemAnalysis* Analysis; @@ -1267,70 +1256,22 @@ void DefineElementsCallback(void* ud, SoEventCallback* n) view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), DefineElementsCallback, ud); n->setHandled(); - Gui::SelectionRole role; - std::vector clPoly = view->getGLPolygon(&role); - if (clPoly.size() < 3) { - return; + std::string str = getSelectedNodes(view); + if (!str.empty()) { + Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Place robot")); + Gui::Command::doCommand( + Gui::Command::Doc, + "App.ActiveDocument.addObject('Fem::FemSetElementNodesObject','ElementSet')"); + Gui::Command::doCommand(Gui::Command::Doc, + "App.ActiveDocument.ActiveObject.Nodes = %s", + str.c_str()); + Gui::Command::doCommand( + Gui::Command::Doc, + "App.activeDocument().%s.addObject(App.activeDocument().ElementSet)", + Analysis->getNameInDocument()); + + Gui::Command::commitCommand(); } - if (clPoly.front() != clPoly.back()) { - clPoly.push_back(clPoly.front()); - } - - SoCamera* cam = view->getSoRenderManager()->getCamera(); - SbViewVolume vv = cam->getViewVolume(); - Gui::ViewVolumeProjection proj(vv); - Base::Polygon2d polygon; - for (std::vector::const_iterator it = clPoly.begin(); it != clPoly.end(); ++it) { - polygon.Add(Base::Vector2d((*it)[0], (*it)[1])); - } - - std::vector docObj = - Gui::Selection().getObjectsOfType(Fem::FemMeshObject::getClassTypeId()); - if (docObj.size() != 1) { - return; - } - - const SMESHDS_Mesh* data = - static_cast(docObj[0])->FemMesh.getValue().getSMesh()->GetMeshDS(); - - SMDS_NodeIteratorPtr aNodeIter = data->nodesIterator(); - Base::Vector3f pt2d; - std::set IntSet; - - while (aNodeIter->more()) { - const SMDS_MeshNode* aNode = aNodeIter->next(); - Base::Vector3f vec(aNode->X(), aNode->Y(), aNode->Z()); - pt2d = proj(vec); - if (polygon.Contains(Base::Vector2d(pt2d.x, pt2d.y))) { - IntSet.insert(aNode->GetID()); - } - } - - std::stringstream set; - - set << "["; - for (std::set::const_iterator it = IntSet.begin(); it != IntSet.end(); ++it) { - if (it == IntSet.begin()) { - set << *it; - } - else { - set << "," << *it; - } - } - set << "]"; - - Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Place robot")); - Gui::Command::doCommand( - Gui::Command::Doc, - "App.ActiveDocument.addObject('Fem::FemSetElementNodesObject','ElementSet')"); - Gui::Command::doCommand(Gui::Command::Doc, - "App.ActiveDocument.ActiveObject.Nodes = %s", - set.str().c_str()); - Gui::Command::doCommand(Gui::Command::Doc, - "App.activeDocument().%s.addObject(App.activeDocument().ElementSet)", - Analysis->getNameInDocument()); - - Gui::Command::commitCommand(); } CmdFemDefineElementsSet::CmdFemDefineElementsSet() From 57489af04392da5a4ba61bfe6e86d7b46e4ec8f4 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 18 Jun 2024 19:58:16 +0200 Subject: [PATCH 4/4] Fem: Clean-up code --- src/Mod/Fem/Gui/TaskCreateElementSet.h | 6 +++--- src/Mod/Fem/Gui/TaskDlgCreateElementSet.cpp | 3 --- src/Mod/Fem/Gui/TaskDlgCreateElementSet.h | 6 +++--- src/Mod/Fem/Gui/ViewProviderSetElementNodes.cpp | 4 +--- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/Mod/Fem/Gui/TaskCreateElementSet.h b/src/Mod/Fem/Gui/TaskCreateElementSet.h index 97a76574c1..d10f1cc994 100644 --- a/src/Mod/Fem/Gui/TaskCreateElementSet.h +++ b/src/Mod/Fem/Gui/TaskCreateElementSet.h @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#ifndef GUI_TASKVIEW_TaskCreateElementSet_H -#define GUI_TASKVIEW_TaskCreateElementSet_H +#ifndef FemGui_TaskCreateElementSet_H +#define FemGui_TaskCreateElementSet_H #include #include @@ -90,4 +90,4 @@ private: } // namespace FemGui -#endif // GUI_TASKVIEW_TaskCreateElementSet_H +#endif // FemGui_TaskCreateElementSet_H diff --git a/src/Mod/Fem/Gui/TaskDlgCreateElementSet.cpp b/src/Mod/Fem/Gui/TaskDlgCreateElementSet.cpp index bbc74ea98b..f591ff014f 100644 --- a/src/Mod/Fem/Gui/TaskDlgCreateElementSet.cpp +++ b/src/Mod/Fem/Gui/TaskDlgCreateElementSet.cpp @@ -69,9 +69,6 @@ bool TaskDlgCreateElementSet::accept() try { FemSetElementNodesObject->Elements.setValues(param->elementTempSet); FemSetElementNodesObject->recomputeFeature(); - // Gui::Document* doc = Gui::Application::Instance->activeDocument(); - // if(doc) - // doc->resetEdit(); param->MeshViewProvider->resetHighlightNodes(); FemSetElementNodesObject->Label.setValue(name->name); Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeDocument().resetEdit()"); diff --git a/src/Mod/Fem/Gui/TaskDlgCreateElementSet.h b/src/Mod/Fem/Gui/TaskDlgCreateElementSet.h index a512c66b67..8bb85f08b7 100644 --- a/src/Mod/Fem/Gui/TaskDlgCreateElementSet.h +++ b/src/Mod/Fem/Gui/TaskDlgCreateElementSet.h @@ -22,8 +22,8 @@ ***************************************************************************/ -#ifndef ROBOTGUI_TaskDlgCreateElementSet_H -#define ROBOTGUI_TaskDlgCreateElementSet_H +#ifndef FemGui_TaskDlgCreateElementSet_H +#define FemGui_TaskDlgCreateElementSet_H #include #include @@ -81,4 +81,4 @@ protected: } // namespace FemGui -#endif // ROBOTGUI_TASKDLGSIMULATE_H +#endif // FemGui_TaskDlgCreateElementSet_H diff --git a/src/Mod/Fem/Gui/ViewProviderSetElementNodes.cpp b/src/Mod/Fem/Gui/ViewProviderSetElementNodes.cpp index d034fd122a..a8f266725f 100644 --- a/src/Mod/Fem/Gui/ViewProviderSetElementNodes.cpp +++ b/src/Mod/Fem/Gui/ViewProviderSetElementNodes.cpp @@ -45,9 +45,7 @@ bool ViewProviderSetElementNodes::doubleClicked() bool ViewProviderSetElementNodes::setEdit(int) { - Gui::TaskView::TaskDialog* dlg = - new TaskDlgCreateElementSet(static_cast(getObject())); - Gui::Control().showDialog(dlg); + doubleClicked(); return true; }