Debian Codegraph @

src/Gui/ViewProviderExtension.h

raw
1 /***************************************************************************
2 * Copyright (c) 2016 Stefan Tröger <[email protected]> *
3 * *
4 * This file is part of the FreeCAD CAx development system. *
5 * *
6 * This library is free software; you can redistribute it and/or *
7 * modify it under the terms of the GNU Library General Public *
8 * License as published by the Free Software Foundation; either *
9 * version 2 of the License, or (at your option) any later version. *
10 * *
11 * This library is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU Library General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Library General Public *
17 * License along with this library; see the file COPYING.LIB. If not, *
18 * write to the Free Software Foundation, Inc., 59 Temple Place, *
19 * Suite 330, Boston, MA 02111-1307, USA *
20 * *
21 ***************************************************************************/
22
23
24 #ifndef GUI_VIEWPROVIDEREXTENSION_H
25 #define GUI_VIEWPROVIDEREXTENSION_H
26
27 #include <QIcon>
28 #include <App/Extension.h>
29
30
31 class SoDetail;
32 class SoFullPath;
33 class SoGroup;
34 class SoPickedPoint;
35 class SoSeparator;
36
37 class QMenu;
38 class QObject;
39
40 namespace Gui
41 {
42
43 class ViewProvider;
44 class ViewProviderDocumentObject;
45
46 /**
47 * @brief Extension with special viewprovider calls
48 *
49 */
50 class GuiExport ViewProviderExtension: public App::Extension
51 {
52 // The class does not have properties itself, but it is important to provide the property access
53 // functions.
54 EXTENSION_PROPERTY_HEADER_WITH_OVERRIDE(Gui::ViewProviderExtension);
55
56 public:
57 ViewProviderExtension();
58 ~ViewProviderExtension() override;
59
60 Gui::ViewProviderDocumentObject* getExtendedViewProvider();
61 const Gui::ViewProviderDocumentObject* getExtendedViewProvider() const;
62
63 virtual std::vector<App::DocumentObject*> extensionClaimChildren3D() const
64 {
65 return {};
66 }
67
68 virtual bool extensionOnDelete(const std::vector<std::string>&)
69 {
70 return true;
71 }
72 virtual void extensionBeforeDelete()
73 {}
74
75 virtual std::vector<App::DocumentObject*> extensionClaimChildren() const
76 {
77 return {};
78 }
79
80 virtual bool extensionCanDragObjects() const
81 {
82 return false;
83 }
84 virtual bool extensionCanDragObject(App::DocumentObject*) const
85 {
86 return true;
87 }
88 virtual void extensionDragObject(App::DocumentObject*)
89 {}
90 virtual bool extensionCanDropObjects() const
91 {
92 return false;
93 }
94 virtual bool extensionCanDropObject(App::DocumentObject*) const
95 {
96 return true;
97 }
98 virtual bool extensionCanDragAndDropObject(App::DocumentObject*) const
99 {
100 return true;
101 }
102 virtual void extensionDropObject(App::DocumentObject*)
103 {}
104 virtual bool extensionCanDropObjectEx(
105 App::DocumentObject*,
106 App::DocumentObject*,
107 const char*,
108 const std::vector<std::string>&
109 ) const
110 {
111 return false;
112 }
113 virtual std::string extensionDropObjectEx(
114 App::DocumentObject* obj,
115 App::DocumentObject*,
116 const char*,
117 const std::vector<std::string>&
118 )
119 {
120 extensionDropObject(obj);
121 return {};
122 }
123
124 virtual int extensionReplaceObject(App::DocumentObject* /*oldValue*/, App::DocumentObject* /*newValue*/)
125 {
126 return -1;
127 }
128
129 /// Hides the view provider
130 virtual void extensionHide()
131 {}
132 /// Shows the view provider
133 virtual void extensionShow()
134 {}
135
136 virtual void extensionModeSwitchChange()
137 {}
138
139 virtual SoSeparator* extensionGetFrontRoot() const
140 {
141 return nullptr;
142 }
143 virtual SoGroup* extensionGetChildRoot() const
144 {
145 return nullptr;
146 }
147 virtual SoSeparator* extensionGetBackRoot() const
148 {
149 return nullptr;
150 }
151 virtual void extensionAttach(App::DocumentObject*)
152 {}
153 virtual void extensionReattach(App::DocumentObject*)
154 {}
155 virtual void extensionSetDisplayMode(const char*)
156 {}
157 virtual std::vector<std::string> extensionGetDisplayModes() const
158 {
159 return {};
160 }
161 virtual void extensionSetupContextMenu(QMenu*, QObject*, const char*)
162 {}
163
164 // update data of extended object
165 virtual void extensionUpdateData(const App::Property*);
166 PyObject* getExtensionPyObject() override;
167
168 void setIgnoreOverlayIcon(bool on)
169 {
170 m_ignoreOverlayIcon = on;
171 }
172 bool ignoreOverlayIcon() const
173 {
174 return m_ignoreOverlayIcon;
175 }
176 virtual QIcon extensionMergeGreyableOverlayIcons(const QIcon& orig) const
177 {
178 return orig;
179 }
180 virtual QIcon extensionMergeColorfullOverlayIcons(const QIcon& orig) const
181 {
182 return orig;
183 }
184
185 virtual void extensionStartRestoring()
186 {}
187 virtual void extensionFinishRestoring()
188 {}
189
190 virtual bool extensionGetElementPicked(const SoPickedPoint*, std::string&) const
191 {
192 return false;
193 }
194 virtual bool extensionGetDetailPath(const char*, SoFullPath*, SoDetail*&) const
195 {
196 return false;
197 }
198
199 private:
200 bool m_ignoreOverlayIcon = false;
201 };
202
203 } // namespace Gui
204
205 #endif // GUI_VIEWPROVIDEREXTENSION_H