Debian Codegraph @

src/Gui/ViewProviderTextureExtension.h

raw
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2
3 /***************************************************************************
4 * Copyright (c) 2024 David Carter <[email protected]> *
5 * *
6 * This file is part of FreeCAD. *
7 * *
8 * FreeCAD is free software: you can redistribute it and/or modify it *
9 * under the terms of the GNU Lesser General Public License as *
10 * published by the Free Software Foundation, either version 2.1 of the *
11 * License, or (at your option) any later version. *
12 * *
13 * FreeCAD is distributed in the hope that it will be useful, but *
14 * WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with FreeCAD. If not, see *
20 * <https://www.gnu.org/licenses/>. *
21 * *
22 **************************************************************************/
23
24
25 #ifndef GUI_VIEWPROVIDERTEXTUREEXT_H
26 #define GUI_VIEWPROVIDERTEXTUREEXT_H
27
28 #include <Gui/ViewProviderExtensionPython.h>
29
30 class SoCoordinate3;
31 class SoGroup;
32 class SoIndexedFaceSet;
33 class SoMaterial;
34 class SoSwitch;
35 class SoTexture2;
36 class SoTexture3;
37
38 namespace App
39 {
40 class Material;
41 }
42
43 namespace Gui
44 {
45
46 class GuiExport ViewProviderTextureExtension: public Gui::ViewProviderExtension
47 {
48 EXTENSION_PROPERTY_HEADER_WITH_OVERRIDE(Gui::ViewProviderTextureExtension);
49
50 public:
51 /// Constructor
52 ViewProviderTextureExtension();
53 ~ViewProviderTextureExtension() override;
54 void setup(SoMaterial*);
55 void setCoinAppearance(SoMaterial* pcShapeMaterial, const App::Material& source);
56 SoSwitch* getAppearance() const;
57 SoGroup* getTextureGroup3D() const;
58
59 /**
60 * Select which appearance type is active
61 *
62 */
63 /** Material only */
64 void activateMaterial();
65 /** 2D Texture */
66 void activateTexture2D();
67 /** 3D texture only */
68 void activateTexture3D();
69 /** Mix of material and 3D textures */
70 void activateMixed3D();
71
72 private:
73 SoSwitch* pcSwitchAppearance {nullptr};
74 SoSwitch* pcSwitchTexture {nullptr};
75 SoTexture2* pcShapeTexture2D {nullptr};
76 SoGroup* pcTextureGroup3D {nullptr};
77 };
78
79 class GuiExport ViewProviderFaceTexture: public Gui::ViewProviderTextureExtension
80 {
81 EXTENSION_PROPERTY_HEADER_WITH_OVERRIDE(Gui::ViewProviderFaceTexture);
82
83 public:
84 /// Constructor
85 ViewProviderFaceTexture();
86 ~ViewProviderFaceTexture() override;
87 void setup(SoMaterial*);
88
89 private:
90 // Used to support per face textures
91 SoTexture3* pcShapeTexture3D;
92 SoCoordinate3* pcShapeCoordinates;
93 SoIndexedFaceSet* pcShapeFaceset;
94 };
95
96 } // namespace Gui
97
98
99 #endif // GUI_VIEWPROVIDERTEXTUREEXT_H