1
/***************************************************************************
2
* Copyright (c) 2008 Werner Mayer <wmayer[at]users.sourceforge.net> *
4
* This file is part of the FreeCAD CAx development system. *
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. *
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. *
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 *
21
***************************************************************************/
23
#include "PreCompiled.h"
29
#include <App/DocumentObjectPy.h>
32
// inclusion of the generated files (generated out of ViewProviderDocumentObjectPy.xml)
33
#include "ViewProviderDocumentObjectPy.h"
34
#include "ViewProviderDocumentObjectPy.cpp"
39
// returns a string which represents the object e.g. when printed in python
40
std::string ViewProviderDocumentObjectPy::representation() const
42
std::stringstream str;
43
str << "<View provider object at " << getViewProviderDocumentObjectPtr() << ">";
48
PyObject* ViewProviderDocumentObjectPy::update(PyObject *args)
50
if (!PyArg_ParseTuple(args, ""))
53
getViewProviderDocumentObjectPtr()->updateView();
58
Py::Object ViewProviderDocumentObjectPy::getObject() const
60
App::DocumentObject* obj = getViewProviderDocumentObjectPtr()->getObject();
61
return Py::Object(obj->getPyObject(), true); // do not inc'ref twice
64
void ViewProviderDocumentObjectPy::setObject(Py::Object pyobj)
66
if(!PyObject_TypeCheck(*pyobj,&App::DocumentObjectPy::Type))
67
throw Py::TypeError("Expect document object");
68
App::DocumentObject* obj = getViewProviderDocumentObjectPtr()->getObject();
70
throw Py::RuntimeError("View object already attached");
71
getViewProviderDocumentObjectPtr()->attach(
72
static_cast<App::DocumentObjectPy*>(*pyobj)->getDocumentObjectPtr());
75
Py::Boolean ViewProviderDocumentObjectPy::getForceUpdate() const
77
return {getViewProviderDocumentObjectPtr()->isUpdateForced()};
80
void ViewProviderDocumentObjectPy::setForceUpdate(Py::Boolean arg)
82
getViewProviderDocumentObjectPtr()->forceUpdate(arg);
85
Py::Object ViewProviderDocumentObjectPy::getDocument() const
87
Document* doc = getViewProviderDocumentObjectPtr()->getDocument();
88
return Py::asObject(doc->getPyObject()); // do not inc'ref twice
91
PyObject *ViewProviderDocumentObjectPy::getCustomAttributes(const char* /*attr*/) const
96
int ViewProviderDocumentObjectPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)