Debian Codegraph @

src/App/DocumentObjectExtension.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 APP_DOCUMENTOBJECTEXTENSION_H
25 #define APP_DOCUMENTOBJECTEXTENSION_H
26
27 #include "Extension.h"
28
29 namespace Base
30 {
31 class Matrix4D;
32 }
33 namespace App
34 {
35 class DocumentObject;
36 class DocumentObjectExecReturn;
37
38 /**
39 * @brief Extension with special document object calls
40 *
41 */
42 class AppExport DocumentObjectExtension: public App::Extension
43 {
44
45 // The cass does not have properties itself, but it is important to provide the property access
46 // functions. see cpp file for details
47 EXTENSION_PROPERTY_HEADER_WITH_OVERRIDE(App::DocumentObjectExtension);
48
49 public:
50 DocumentObjectExtension();
51 ~DocumentObjectExtension() override;
52
53 App::DocumentObject* getExtendedObject();
54 const App::DocumentObject* getExtendedObject() const;
55
56 // override if execution is necessary
57 virtual short extensionMustExecute();
58 virtual App::DocumentObjectExecReturn* extensionExecute();
59
60
61 /// get called after setting the document
62 virtual void onExtendedSettingDocument();
63 /// get called after a document has been fully restored
64 virtual void onExtendedDocumentRestored();
65 /// get called after a brand new object was created
66 virtual void onExtendedSetupObject();
67 /// get called when object is going to be removed from the document
68 virtual void onExtendedUnsetupObject();
69
70 PyObject* getExtensionPyObject() override;
71
72 /// returns the type name of the ViewProviderExtension which is automatically attached
73 /// to the viewprovider object when it is initiated
74 virtual const char* getViewProviderExtensionName() const
75 {
76 return "";
77 }
78
79 /** Get the sub object by name
80 * @sa DocumentObject::getSubObject()
81 *
82 * @return Return turn if handled, the sub object is returned in \c ret
83 */
84 virtual bool extensionGetSubObject(DocumentObject*& ret,
85 const char* subname,
86 PyObject** pyObj,
87 Base::Matrix4D* mat,
88 bool transform,
89 int depth) const;
90
91 /** Get name references of all sub objects
92 * @sa DocumentObject::getSubObjects()
93 *
94 * @return Return turn if handled, the sub object is returned in \c ret
95 */
96 virtual bool extensionGetSubObjects(std::vector<std::string>& ret, int reason) const;
97
98 /** Get the linked object
99 * @sa DocumentObject::getLinkedObject()
100 *
101 * @return Return turn if handled, the linked object is returned in \c ret
102 */
103 virtual bool extensionGetLinkedObject(DocumentObject*& ret,
104 bool recursive,
105 Base::Matrix4D* mat,
106 bool transform,
107 int depth) const;
108
109 virtual int extensionSetElementVisible(const char*, bool)
110 {
111 return -1;
112 }
113 virtual int extensionIsElementVisible(const char*)
114 {
115 return -1;
116 }
117 virtual bool extensionHasChildElement() const
118 {
119 return false;
120 }
121 };
122
123 } // namespace App
124
125 #endif // APP_DOCUMENTOBJECTEXTENSION_H