diff --git a/src/Mod/Import/Gui/AppImportGuiPy.cpp b/src/Mod/Import/Gui/AppImportGuiPy.cpp index 3bd32997af80..1996939ef56e 100644 --- a/src/Mod/Import/Gui/AppImportGuiPy.cpp +++ b/src/Mod/Import/Gui/AppImportGuiPy.cpp @@ -85,6 +85,8 @@ #endif #endif +#include "ExportOCAFGui.h" + #include #include #include @@ -343,25 +345,6 @@ class ImportOCAFExt: public Import::ImportOCAF2 } }; -class ExportOCAFGui: public Import::ExportOCAF -{ -public: - ExportOCAFGui(Handle(TDocStd_Document) h, bool explicitPlacement) - : ExportOCAF(h, explicitPlacement) - {} - void findColors(Part::Feature* part, std::vector& colors) const override - { - Gui::ViewProvider* vp = Gui::Application::Instance->getViewProvider(part); - if (vp && vp->isDerivedFrom(PartGui::ViewProviderPartExt::getClassTypeId())) { - colors = static_cast(vp)->DiffuseColor.getValues(); - if (colors.empty()) { - colors.push_back( - static_cast(vp)->ShapeColor.getValue()); - } - } - } -}; - class Module: public Py::ExtensionModule { public: diff --git a/src/Mod/Import/Gui/CMakeLists.txt b/src/Mod/Import/Gui/CMakeLists.txt index a0fae5a58d26..0020c6c61d0b 100644 --- a/src/Mod/Import/Gui/CMakeLists.txt +++ b/src/Mod/Import/Gui/CMakeLists.txt @@ -30,6 +30,8 @@ SET(ImportGui_SRCS AppImportGui.cpp AppImportGuiPy.cpp Command.cpp + ExportOCAFGui.cpp + ExportOCAFGui.h PreCompiled.cpp PreCompiled.h Workbench.cpp diff --git a/src/Mod/Import/Gui/ExportOCAFGui.cpp b/src/Mod/Import/Gui/ExportOCAFGui.cpp new file mode 100644 index 000000000000..8d92481c01c5 --- /dev/null +++ b/src/Mod/Import/Gui/ExportOCAFGui.cpp @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later + +/*************************************************************************** + * Copyright (c) 2023 Werner Mayer * + * * + * 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 * + * . * + * * + **************************************************************************/ + + +#include "PreCompiled.h" + +#include "ExportOCAFGui.h" +#include +#include + +using namespace ImportGui; + + +ExportOCAFGui::ExportOCAFGui(Handle(TDocStd_Document) hDoc, bool explicitPlacement) + : ExportOCAF(hDoc, explicitPlacement) +{} + +void ExportOCAFGui::findColors(Part::Feature* part, std::vector& colors) const +{ + Gui::ViewProvider* vp = Gui::Application::Instance->getViewProvider(part); + if (vp && vp->isDerivedFrom(PartGui::ViewProviderPartExt::getClassTypeId())) { + colors = static_cast(vp)->DiffuseColor.getValues(); + if (colors.empty()) { + colors.push_back(static_cast(vp)->ShapeColor.getValue()); + } + } +} diff --git a/src/Mod/Import/Gui/ExportOCAFGui.h b/src/Mod/Import/Gui/ExportOCAFGui.h new file mode 100644 index 000000000000..6c31b7f48dd5 --- /dev/null +++ b/src/Mod/Import/Gui/ExportOCAFGui.h @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later + +/*************************************************************************** + * Copyright (c) 2023 Werner Mayer * + * * + * 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 * + * . * + * * + **************************************************************************/ + +#ifndef IMPORT_EXPORTOCAFGUI_H +#define IMPORT_EXPORTOCAFGUI_H + +#include + +namespace ImportGui +{ + +class ExportOCAFGui: public Import::ExportOCAF +{ +public: + ExportOCAFGui(Handle(TDocStd_Document) hDoc, bool explicitPlacement); + void findColors(Part::Feature* part, std::vector& colors) const override; +}; + +} // namespace ImportGui + +#endif // IMPORT_EXPORTOCAFGUI_H