// SPDX-License-Identifier: LGPL-2.1-or-later /**************************************************************************** * * * Copyright (c) 2025 Kacper Donat * * * * 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 PARTGUI_VIEWPROVIDERPREVIEWEXTENSION_H #define PARTGUI_VIEWPROVIDERPREVIEWEXTENSION_H #include "SoBrepEdgeSet.h" #include "SoBrepFaceSet.h" #include "SoBrepPointSet.h" #include #include #include #include #include #include #include #include #include #include #include #include namespace PartGui { class PartGuiExport SoPreviewShape : public SoSeparator { using inherited = SoSeparator; SO_NODE_HEADER(SoPreviewShape); public: static constexpr float defaultTransparency = 0.8F; static constexpr float defaultLineWidth = 2.0F; static const SbColor defaultColor; SoPreviewShape(); SoSFColor color; SoSFFloat transparency; SoSFFloat lineWidth; SoCoordinate3* coords; SoNormal* norm; SoBrepFaceSet* faceset; SoBrepEdgeSet* lineset; SoBrepPointSet* nodeset; }; class PartGuiExport ViewProviderPreviewExtension : public Gui::ViewProviderExtension { Q_DECLARE_TR_FUNCTIONS(PartDesignGui::ViewProviderPreviewExtension) EXTENSION_PROPERTY_HEADER_WITH_OVERRIDE(Gui::ViewProviderPreviewExtension); public: App::PropertyColor PreviewColor; ViewProviderPreviewExtension(); /// Returns shape that should be used as the preview virtual Part::TopoShape getPreviewShape() const { return Part::TopoShape(); }; void extensionAttach(App::DocumentObject*) override; void extensionBeforeDelete() override; /// Returns whatever preview is enabled or not bool isPreviewEnabled() const { return _isPreviewEnabled; } /// Switches preview on or off virtual void showPreview(bool enable); protected: void extensionOnChanged(const App::Property* prop) override; /// updates geometry of the preview shape void updatePreviewShape(); Gui::CoinPtr pcPreviewRoot; Gui::CoinPtr pcPreviewShape; private: bool _isPreviewEnabled {false}; }; using ViewProviderPreviewExtensionPython = Gui::ViewProviderExtensionPythonT; } #endif // PARTGUI_VIEWPROVIDERPREVIEWEXTENSION_H