| 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 |
#include "DocumentObjectExtension.h" |
| 24 |
#include "DocumentObjectExtensionPy.h" |
| 25 |
#include "DocumentObject.h" |
| 26 |
#include "ExtensionContainer.h" |
| 27 |
|
| 28 |
using namespace App; |
| 29 |
|
| 30 |
EXTENSION_PROPERTY_SOURCE(App::DocumentObjectExtension, App::Extension) |
| 31 |
|
| 32 |
DocumentObjectExtension::DocumentObjectExtension() |
| 33 |
{ |
| 34 |
initExtensionType(App::DocumentObjectExtension::getExtensionClassTypeId()); |
| 35 |
} |
| 36 |
|
| 37 |
DocumentObjectExtension::~DocumentObjectExtension() = default; |
| 38 |
|
| 39 |
short int DocumentObjectExtension::extensionMustExecute() |
| 40 |
{ |
| 41 |
|
| 42 |
return 0; |
| 43 |
} |
| 44 |
|
| 45 |
App::DocumentObjectExecReturn* DocumentObjectExtension::extensionExecute() |
| 46 |
{ |
| 47 |
|
| 48 |
return App::DocumentObject::StdReturn; |
| 49 |
} |
| 50 |
|
| 51 |
void DocumentObjectExtension::onExtendedSettingDocument() |
| 52 |
{} |
| 53 |
|
| 54 |
void DocumentObjectExtension::onExtendedDocumentRestored() |
| 55 |
{} |
| 56 |
|
| 57 |
void DocumentObjectExtension::onExtendedSetupObject() |
| 58 |
{} |
| 59 |
|
| 60 |
void DocumentObjectExtension::onExtendedUnsetupObject() |
| 61 |
{} |
| 62 |
|
| 63 |
PyObject* DocumentObjectExtension::getExtensionPyObject() |
| 64 |
{ |
| 65 |
|
| 66 |
if (ExtensionPythonObject.is(Py::_None())) { |
| 67 |
// ref counter is set to 1 |
| 68 |
ExtensionPythonObject = Py::Object(new DocumentObjectExtensionPy(this), true); |
| 69 |
} |
| 70 |
return Py::new_reference_to(ExtensionPythonObject); |
| 71 |
} |
| 72 |
|
| 73 |
const DocumentObject* DocumentObjectExtension::getExtendedObject() const |
| 74 |
{ |
| 75 |
|
| 76 |
assert(getExtendedContainer()->isDerivedFrom<DocumentObject>()); |
| 77 |
return static_cast<const DocumentObject*>(getExtendedContainer()); |
| 78 |
} |
| 79 |
|
| 80 |
DocumentObject* DocumentObjectExtension::getExtendedObject() |
| 81 |
{ |
| 82 |
|
| 83 |
assert(getExtendedContainer()->isDerivedFrom<DocumentObject>()); |
| 84 |
return static_cast<DocumentObject*>(getExtendedContainer()); |
| 85 |
} |
| 86 |
|
| 87 |
bool DocumentObjectExtension::extensionGetSubObject(DocumentObject*&, |
| 88 |
const char*, |
| 89 |
PyObject**, |
| 90 |
Base::Matrix4D*, |
| 91 |
bool, |
| 92 |
int) const |
| 93 |
{ |
| 94 |
return false; |
| 95 |
} |
| 96 |
|
| 97 |
bool DocumentObjectExtension::extensionGetSubObjects(std::vector<std::string>&, int) const |
| 98 |
{ |
| 99 |
return false; |
| 100 |
} |
| 101 |
|
| 102 |
bool DocumentObjectExtension::extensionGetLinkedObject(DocumentObject*&, |
| 103 |
bool, |
| 104 |
Base::Matrix4D*, |
| 105 |
bool, |
| 106 |
int) const |
| 107 |
{ |
| 108 |
return false; |
| 109 |
} |