Debian Codegraph @

src/App/OriginGroupExtension.h

raw
1 /***************************************************************************
2 * Copyright (c) 2015 Alexander Golubev (Fat-Zer) <[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 #ifndef ORIGINGROUP_H_QHTU73IF
24 #define ORIGINGROUP_H_QHTU73IF
25
26 #include "GeoFeatureGroupExtension.h"
27 #include "QCoreApplication"
28
29 namespace App
30 {
31 class Origin;
32
33 /**
34 * Represents an abstract placeable group of objects with an associated Origin
35 */
36 class AppExport OriginGroupExtension: public App::GeoFeatureGroupExtension
37 {
38 EXTENSION_PROPERTY_HEADER_WITH_OVERRIDE(App::OriginGroupExtension);
39 Q_DECLARE_TR_FUNCTIONS(App::OriginGroupExtension)
40
41 public:
42 OriginGroupExtension();
43 ~OriginGroupExtension() override;
44
45 /// Returns the origin link or throws an exception
46 App::Origin* getOrigin() const;
47
48 /// returns the type name of the ViewProvider
49 virtual const char* getViewProviderName() const
50 {
51 return "Gui::ViewProviderOriginGroup";
52 }
53
54 /**
55 * Returns the origin group which contains this object.
56 * In case this object is not part of any geoFeatureGroup, 0 is returned.
57 * @param obj the object to search for
58 */
59 static DocumentObject* getGroupOfObject(const DocumentObject* obj);
60
61 /// Returns true on changing OriginFeature set
62 short extensionMustExecute() override;
63
64 /// Origin linked to the group
65 PropertyLink Origin;
66
67 // changes all links of obj to a origin to point to this groups origin
68 void relinkToOrigin(App::DocumentObject* obj);
69
70 std::vector<DocumentObject*> addObjects(std::vector<DocumentObject*> obj) override;
71 bool hasObject(const DocumentObject* obj, bool recursive = false) const override;
72
73 bool extensionGetSubObject(DocumentObject*& ret,
74 const char* subname,
75 PyObject** pyObj,
76 Base::Matrix4D* mat,
77 bool transform,
78 int depth) const override;
79
80 void extensionOnChanged(const Property* p) override;
81
82 protected:
83 /// Checks integrity of the Origin
84 App::DocumentObjectExecReturn* extensionExecute() override;
85 /// Creates the corresponding Origin object
86 void onExtendedSetupObject() override;
87 /// Removes all planes and axis if they are still linked to the document
88 void onExtendedUnsetupObject() override;
89
90 private:
91 /// Creates a localized Origin object
92 App::DocumentObject* getLocalizedOrigin(App::Document* doc);
93 };
94
95 using OriginGroupExtensionPython = ExtensionPythonT<GroupExtensionPythonT<OriginGroupExtension>>;
96
97 } // namespace App
98
99 #endif /* end of include guard: ORIGINGROUP_H_QHTU73IF */