00001
00002
00003
00004
00005
00006 #include <boost/filesystem/path.hpp>
00007 #include <boost/filesystem/operations.hpp>
00008 #include <boost/filesystem/exception.hpp>
00009 #include <Base/PyObjectBase.h>
00010 #include <Base/Console.h>
00011 #include <Base/Exception.h>
00012 #include <CXX/Objects.hxx>
00013
00014 #define new DEBUG_CLIENTBLOCK
00015
00016 using Base::streq;
00017 using namespace Gui;
00018
00020 PyTypeObject DocumentPy::Type = {
00021 PyObject_HEAD_INIT(&PyType_Type)
00022 0,
00023 "Gui.Document",
00024 sizeof(DocumentPy),
00025 0,
00026
00027 PyDestructor,
00028 0,
00029 __getattr,
00030 __setattr,
00031 0,
00032 __repr,
00033 0,
00034 0,
00035 0,
00036 0,
00037 0,
00038 0,
00039 0,
00040 0,
00041
00042 0,
00043
00044 Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_CLASS,
00045 "This is a Document class",
00046 0,
00047 0,
00048 0,
00049 0,
00050 0,
00051 0,
00052 Gui::DocumentPy::Methods,
00053 0,
00054 Gui::DocumentPy::GetterSetter,
00055 &Base::PersistencePy::Type,
00056 0,
00057 0,
00058 0,
00059 0,
00060 __PyInit,
00061 0,
00062 Gui::DocumentPy::PyMake,
00063 0,
00064 0,
00065 0,
00066 0,
00067 0,
00068 0,
00069 0,
00070 0
00071 };
00072
00074 PyMethodDef DocumentPy::Methods[] = {
00075 {"show",
00076 (PyCFunction) staticCallback_show,
00077 METH_VARARGS,
00078 "Show the object"
00079 },
00080 {"hide",
00081 (PyCFunction) staticCallback_hide,
00082 METH_VARARGS,
00083 "Hide the object"
00084 },
00085 {"setPos",
00086 (PyCFunction) staticCallback_setPos,
00087 METH_VARARGS,
00088 "Set the position"
00089 },
00090 {"setEdit",
00091 (PyCFunction) staticCallback_setEdit,
00092 METH_VARARGS,
00093 "\n setEdit([String:Name|ViewProvider|DocumentObjet]|,mod)\n Set the given object in edit mode.\n "
00094 },
00095 {"resetEdit",
00096 (PyCFunction) staticCallback_resetEdit,
00097 METH_VARARGS,
00098 "\n Reset (end) the current editing.\n "
00099 },
00100 {"addAnnotation",
00101 (PyCFunction) staticCallback_addAnnotation,
00102 METH_VARARGS,
00103 "Add an Inventor object"
00104 },
00105 {"update",
00106 (PyCFunction) staticCallback_update,
00107 METH_VARARGS,
00108 "Update the view representations of all objects"
00109 },
00110 {"getObject",
00111 (PyCFunction) staticCallback_getObject,
00112 METH_VARARGS,
00113 "Return the object with the given name"
00114 },
00115 {"activeObject",
00116 (PyCFunction) staticCallback_activeObject,
00117 METH_VARARGS,
00118 "deprecated -- use ActiveObject"
00119 },
00120 {"activeView",
00121 (PyCFunction) staticCallback_activeView,
00122 METH_VARARGS,
00123 "deprecated -- use ActiveView"
00124 },
00125 {NULL, NULL, 0, NULL}
00126 };
00127
00128
00129
00131 PyGetSetDef DocumentPy::GetterSetter[] = {
00132 {"ActiveObject",
00133 (getter) staticCallback_getActiveObject,
00134 (setter) staticCallback_setActiveObject,
00135 "The active object of the document",
00136 NULL
00137 },
00138 {"ActiveView",
00139 (getter) staticCallback_getActiveView,
00140 (setter) staticCallback_setActiveView,
00141 "The active view of the document",
00142 NULL
00143 },
00144 {"Document",
00145 (getter) staticCallback_getDocument,
00146 (setter) staticCallback_setDocument,
00147 "The related App document to this Gui document",
00148 NULL
00149 },
00150 {NULL, NULL, NULL, NULL, NULL}
00151 };
00152
00153
00154
00155
00156 PyObject * DocumentPy::staticCallback_show (PyObject *self, PyObject *args)
00157 {
00158
00159 if (!((PyObjectBase*) self)->isValid()){
00160 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00161 return NULL;
00162 }
00163
00164
00165 if (((PyObjectBase*) self)->isConst()){
00166 PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00167 return NULL;
00168 }
00169
00170 try {
00171 PyObject* ret = ((DocumentPy*)self)->show(args);
00172 if (ret != 0)
00173 ((DocumentPy*)self)->startNotify();
00174 return ret;
00175 }
00176 catch(const Base::Exception& e)
00177 {
00178 std::string str;
00179 str += "FreeCAD exception thrown (";
00180 str += e.what();
00181 str += ")";
00182 e.ReportException();
00183 PyErr_SetString(PyExc_Exception,str.c_str());
00184 return NULL;
00185 }
00186 catch(const boost::filesystem::filesystem_error& e)
00187 {
00188 std::string str;
00189 str += "File system exception thrown (";
00190
00191
00192 str += e.what();
00193 str += ")\n";
00194 Base::Console().Error(str.c_str());
00195 PyErr_SetString(PyExc_Exception,str.c_str());
00196 return NULL;
00197 }
00198 catch(const Py::Exception&)
00199 {
00200
00201 return NULL;
00202 }
00203 catch(const char* e)
00204 {
00205 Base::Console().Error(e);
00206 PyErr_SetString(PyExc_Exception,e);
00207 return NULL;
00208 }
00209
00210 #ifndef DONT_CATCH_CXX_EXCEPTIONS
00211 catch(const std::exception& e)
00212 {
00213 std::string str;
00214 str += "FC++ exception thrown (";
00215 str += e.what();
00216 str += ")";
00217 Base::Console().Error(str.c_str());
00218 PyErr_SetString(PyExc_Exception,str.c_str());
00219 return NULL;
00220 }
00221 catch(...)
00222 {
00223 PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00224 return NULL;
00225 }
00226 #endif
00227 }
00228
00229
00230
00231
00232 PyObject * DocumentPy::staticCallback_hide (PyObject *self, PyObject *args)
00233 {
00234
00235 if (!((PyObjectBase*) self)->isValid()){
00236 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00237 return NULL;
00238 }
00239
00240
00241 if (((PyObjectBase*) self)->isConst()){
00242 PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00243 return NULL;
00244 }
00245
00246 try {
00247 PyObject* ret = ((DocumentPy*)self)->hide(args);
00248 if (ret != 0)
00249 ((DocumentPy*)self)->startNotify();
00250 return ret;
00251 }
00252 catch(const Base::Exception& e)
00253 {
00254 std::string str;
00255 str += "FreeCAD exception thrown (";
00256 str += e.what();
00257 str += ")";
00258 e.ReportException();
00259 PyErr_SetString(PyExc_Exception,str.c_str());
00260 return NULL;
00261 }
00262 catch(const boost::filesystem::filesystem_error& e)
00263 {
00264 std::string str;
00265 str += "File system exception thrown (";
00266
00267
00268 str += e.what();
00269 str += ")\n";
00270 Base::Console().Error(str.c_str());
00271 PyErr_SetString(PyExc_Exception,str.c_str());
00272 return NULL;
00273 }
00274 catch(const Py::Exception&)
00275 {
00276
00277 return NULL;
00278 }
00279 catch(const char* e)
00280 {
00281 Base::Console().Error(e);
00282 PyErr_SetString(PyExc_Exception,e);
00283 return NULL;
00284 }
00285
00286 #ifndef DONT_CATCH_CXX_EXCEPTIONS
00287 catch(const std::exception& e)
00288 {
00289 std::string str;
00290 str += "FC++ exception thrown (";
00291 str += e.what();
00292 str += ")";
00293 Base::Console().Error(str.c_str());
00294 PyErr_SetString(PyExc_Exception,str.c_str());
00295 return NULL;
00296 }
00297 catch(...)
00298 {
00299 PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00300 return NULL;
00301 }
00302 #endif
00303 }
00304
00305
00306
00307
00308 PyObject * DocumentPy::staticCallback_setPos (PyObject *self, PyObject *args)
00309 {
00310
00311 if (!((PyObjectBase*) self)->isValid()){
00312 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00313 return NULL;
00314 }
00315
00316
00317 if (((PyObjectBase*) self)->isConst()){
00318 PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00319 return NULL;
00320 }
00321
00322 try {
00323 PyObject* ret = ((DocumentPy*)self)->setPos(args);
00324 if (ret != 0)
00325 ((DocumentPy*)self)->startNotify();
00326 return ret;
00327 }
00328 catch(const Base::Exception& e)
00329 {
00330 std::string str;
00331 str += "FreeCAD exception thrown (";
00332 str += e.what();
00333 str += ")";
00334 e.ReportException();
00335 PyErr_SetString(PyExc_Exception,str.c_str());
00336 return NULL;
00337 }
00338 catch(const boost::filesystem::filesystem_error& e)
00339 {
00340 std::string str;
00341 str += "File system exception thrown (";
00342
00343
00344 str += e.what();
00345 str += ")\n";
00346 Base::Console().Error(str.c_str());
00347 PyErr_SetString(PyExc_Exception,str.c_str());
00348 return NULL;
00349 }
00350 catch(const Py::Exception&)
00351 {
00352
00353 return NULL;
00354 }
00355 catch(const char* e)
00356 {
00357 Base::Console().Error(e);
00358 PyErr_SetString(PyExc_Exception,e);
00359 return NULL;
00360 }
00361
00362 #ifndef DONT_CATCH_CXX_EXCEPTIONS
00363 catch(const std::exception& e)
00364 {
00365 std::string str;
00366 str += "FC++ exception thrown (";
00367 str += e.what();
00368 str += ")";
00369 Base::Console().Error(str.c_str());
00370 PyErr_SetString(PyExc_Exception,str.c_str());
00371 return NULL;
00372 }
00373 catch(...)
00374 {
00375 PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00376 return NULL;
00377 }
00378 #endif
00379 }
00380
00381
00382
00383
00384 PyObject * DocumentPy::staticCallback_setEdit (PyObject *self, PyObject *args)
00385 {
00386
00387 if (!((PyObjectBase*) self)->isValid()){
00388 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00389 return NULL;
00390 }
00391
00392
00393 if (((PyObjectBase*) self)->isConst()){
00394 PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00395 return NULL;
00396 }
00397
00398 try {
00399 PyObject* ret = ((DocumentPy*)self)->setEdit(args);
00400 if (ret != 0)
00401 ((DocumentPy*)self)->startNotify();
00402 return ret;
00403 }
00404 catch(const Base::Exception& e)
00405 {
00406 std::string str;
00407 str += "FreeCAD exception thrown (";
00408 str += e.what();
00409 str += ")";
00410 e.ReportException();
00411 PyErr_SetString(PyExc_Exception,str.c_str());
00412 return NULL;
00413 }
00414 catch(const boost::filesystem::filesystem_error& e)
00415 {
00416 std::string str;
00417 str += "File system exception thrown (";
00418
00419
00420 str += e.what();
00421 str += ")\n";
00422 Base::Console().Error(str.c_str());
00423 PyErr_SetString(PyExc_Exception,str.c_str());
00424 return NULL;
00425 }
00426 catch(const Py::Exception&)
00427 {
00428
00429 return NULL;
00430 }
00431 catch(const char* e)
00432 {
00433 Base::Console().Error(e);
00434 PyErr_SetString(PyExc_Exception,e);
00435 return NULL;
00436 }
00437
00438 #ifndef DONT_CATCH_CXX_EXCEPTIONS
00439 catch(const std::exception& e)
00440 {
00441 std::string str;
00442 str += "FC++ exception thrown (";
00443 str += e.what();
00444 str += ")";
00445 Base::Console().Error(str.c_str());
00446 PyErr_SetString(PyExc_Exception,str.c_str());
00447 return NULL;
00448 }
00449 catch(...)
00450 {
00451 PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00452 return NULL;
00453 }
00454 #endif
00455 }
00456
00457
00458
00459
00460 PyObject * DocumentPy::staticCallback_resetEdit (PyObject *self, PyObject *args)
00461 {
00462
00463 if (!((PyObjectBase*) self)->isValid()){
00464 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00465 return NULL;
00466 }
00467
00468
00469 if (((PyObjectBase*) self)->isConst()){
00470 PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00471 return NULL;
00472 }
00473
00474 try {
00475 PyObject* ret = ((DocumentPy*)self)->resetEdit(args);
00476 if (ret != 0)
00477 ((DocumentPy*)self)->startNotify();
00478 return ret;
00479 }
00480 catch(const Base::Exception& e)
00481 {
00482 std::string str;
00483 str += "FreeCAD exception thrown (";
00484 str += e.what();
00485 str += ")";
00486 e.ReportException();
00487 PyErr_SetString(PyExc_Exception,str.c_str());
00488 return NULL;
00489 }
00490 catch(const boost::filesystem::filesystem_error& e)
00491 {
00492 std::string str;
00493 str += "File system exception thrown (";
00494
00495
00496 str += e.what();
00497 str += ")\n";
00498 Base::Console().Error(str.c_str());
00499 PyErr_SetString(PyExc_Exception,str.c_str());
00500 return NULL;
00501 }
00502 catch(const Py::Exception&)
00503 {
00504
00505 return NULL;
00506 }
00507 catch(const char* e)
00508 {
00509 Base::Console().Error(e);
00510 PyErr_SetString(PyExc_Exception,e);
00511 return NULL;
00512 }
00513
00514 #ifndef DONT_CATCH_CXX_EXCEPTIONS
00515 catch(const std::exception& e)
00516 {
00517 std::string str;
00518 str += "FC++ exception thrown (";
00519 str += e.what();
00520 str += ")";
00521 Base::Console().Error(str.c_str());
00522 PyErr_SetString(PyExc_Exception,str.c_str());
00523 return NULL;
00524 }
00525 catch(...)
00526 {
00527 PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00528 return NULL;
00529 }
00530 #endif
00531 }
00532
00533
00534
00535
00536 PyObject * DocumentPy::staticCallback_addAnnotation (PyObject *self, PyObject *args)
00537 {
00538
00539 if (!((PyObjectBase*) self)->isValid()){
00540 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00541 return NULL;
00542 }
00543
00544
00545 if (((PyObjectBase*) self)->isConst()){
00546 PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00547 return NULL;
00548 }
00549
00550 try {
00551 PyObject* ret = ((DocumentPy*)self)->addAnnotation(args);
00552 if (ret != 0)
00553 ((DocumentPy*)self)->startNotify();
00554 return ret;
00555 }
00556 catch(const Base::Exception& e)
00557 {
00558 std::string str;
00559 str += "FreeCAD exception thrown (";
00560 str += e.what();
00561 str += ")";
00562 e.ReportException();
00563 PyErr_SetString(PyExc_Exception,str.c_str());
00564 return NULL;
00565 }
00566 catch(const boost::filesystem::filesystem_error& e)
00567 {
00568 std::string str;
00569 str += "File system exception thrown (";
00570
00571
00572 str += e.what();
00573 str += ")\n";
00574 Base::Console().Error(str.c_str());
00575 PyErr_SetString(PyExc_Exception,str.c_str());
00576 return NULL;
00577 }
00578 catch(const Py::Exception&)
00579 {
00580
00581 return NULL;
00582 }
00583 catch(const char* e)
00584 {
00585 Base::Console().Error(e);
00586 PyErr_SetString(PyExc_Exception,e);
00587 return NULL;
00588 }
00589
00590 #ifndef DONT_CATCH_CXX_EXCEPTIONS
00591 catch(const std::exception& e)
00592 {
00593 std::string str;
00594 str += "FC++ exception thrown (";
00595 str += e.what();
00596 str += ")";
00597 Base::Console().Error(str.c_str());
00598 PyErr_SetString(PyExc_Exception,str.c_str());
00599 return NULL;
00600 }
00601 catch(...)
00602 {
00603 PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00604 return NULL;
00605 }
00606 #endif
00607 }
00608
00609
00610
00611
00612 PyObject * DocumentPy::staticCallback_update (PyObject *self, PyObject *args)
00613 {
00614
00615 if (!((PyObjectBase*) self)->isValid()){
00616 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00617 return NULL;
00618 }
00619
00620
00621 if (((PyObjectBase*) self)->isConst()){
00622 PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00623 return NULL;
00624 }
00625
00626 try {
00627 PyObject* ret = ((DocumentPy*)self)->update(args);
00628 if (ret != 0)
00629 ((DocumentPy*)self)->startNotify();
00630 return ret;
00631 }
00632 catch(const Base::Exception& e)
00633 {
00634 std::string str;
00635 str += "FreeCAD exception thrown (";
00636 str += e.what();
00637 str += ")";
00638 e.ReportException();
00639 PyErr_SetString(PyExc_Exception,str.c_str());
00640 return NULL;
00641 }
00642 catch(const boost::filesystem::filesystem_error& e)
00643 {
00644 std::string str;
00645 str += "File system exception thrown (";
00646
00647
00648 str += e.what();
00649 str += ")\n";
00650 Base::Console().Error(str.c_str());
00651 PyErr_SetString(PyExc_Exception,str.c_str());
00652 return NULL;
00653 }
00654 catch(const Py::Exception&)
00655 {
00656
00657 return NULL;
00658 }
00659 catch(const char* e)
00660 {
00661 Base::Console().Error(e);
00662 PyErr_SetString(PyExc_Exception,e);
00663 return NULL;
00664 }
00665
00666 #ifndef DONT_CATCH_CXX_EXCEPTIONS
00667 catch(const std::exception& e)
00668 {
00669 std::string str;
00670 str += "FC++ exception thrown (";
00671 str += e.what();
00672 str += ")";
00673 Base::Console().Error(str.c_str());
00674 PyErr_SetString(PyExc_Exception,str.c_str());
00675 return NULL;
00676 }
00677 catch(...)
00678 {
00679 PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00680 return NULL;
00681 }
00682 #endif
00683 }
00684
00685
00686
00687
00688 PyObject * DocumentPy::staticCallback_getObject (PyObject *self, PyObject *args)
00689 {
00690
00691 if (!((PyObjectBase*) self)->isValid()){
00692 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00693 return NULL;
00694 }
00695
00696
00697 if (((PyObjectBase*) self)->isConst()){
00698 PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00699 return NULL;
00700 }
00701
00702 try {
00703 PyObject* ret = ((DocumentPy*)self)->getObject(args);
00704 if (ret != 0)
00705 ((DocumentPy*)self)->startNotify();
00706 return ret;
00707 }
00708 catch(const Base::Exception& e)
00709 {
00710 std::string str;
00711 str += "FreeCAD exception thrown (";
00712 str += e.what();
00713 str += ")";
00714 e.ReportException();
00715 PyErr_SetString(PyExc_Exception,str.c_str());
00716 return NULL;
00717 }
00718 catch(const boost::filesystem::filesystem_error& e)
00719 {
00720 std::string str;
00721 str += "File system exception thrown (";
00722
00723
00724 str += e.what();
00725 str += ")\n";
00726 Base::Console().Error(str.c_str());
00727 PyErr_SetString(PyExc_Exception,str.c_str());
00728 return NULL;
00729 }
00730 catch(const Py::Exception&)
00731 {
00732
00733 return NULL;
00734 }
00735 catch(const char* e)
00736 {
00737 Base::Console().Error(e);
00738 PyErr_SetString(PyExc_Exception,e);
00739 return NULL;
00740 }
00741
00742 #ifndef DONT_CATCH_CXX_EXCEPTIONS
00743 catch(const std::exception& e)
00744 {
00745 std::string str;
00746 str += "FC++ exception thrown (";
00747 str += e.what();
00748 str += ")";
00749 Base::Console().Error(str.c_str());
00750 PyErr_SetString(PyExc_Exception,str.c_str());
00751 return NULL;
00752 }
00753 catch(...)
00754 {
00755 PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00756 return NULL;
00757 }
00758 #endif
00759 }
00760
00761
00762
00763
00764 PyObject * DocumentPy::staticCallback_activeObject (PyObject *self, PyObject *args)
00765 {
00766
00767 if (!((PyObjectBase*) self)->isValid()){
00768 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00769 return NULL;
00770 }
00771
00772
00773 if (((PyObjectBase*) self)->isConst()){
00774 PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00775 return NULL;
00776 }
00777
00778 try {
00779 PyObject* ret = ((DocumentPy*)self)->activeObject(args);
00780 if (ret != 0)
00781 ((DocumentPy*)self)->startNotify();
00782 return ret;
00783 }
00784 catch(const Base::Exception& e)
00785 {
00786 std::string str;
00787 str += "FreeCAD exception thrown (";
00788 str += e.what();
00789 str += ")";
00790 e.ReportException();
00791 PyErr_SetString(PyExc_Exception,str.c_str());
00792 return NULL;
00793 }
00794 catch(const boost::filesystem::filesystem_error& e)
00795 {
00796 std::string str;
00797 str += "File system exception thrown (";
00798
00799
00800 str += e.what();
00801 str += ")\n";
00802 Base::Console().Error(str.c_str());
00803 PyErr_SetString(PyExc_Exception,str.c_str());
00804 return NULL;
00805 }
00806 catch(const Py::Exception&)
00807 {
00808
00809 return NULL;
00810 }
00811 catch(const char* e)
00812 {
00813 Base::Console().Error(e);
00814 PyErr_SetString(PyExc_Exception,e);
00815 return NULL;
00816 }
00817
00818 #ifndef DONT_CATCH_CXX_EXCEPTIONS
00819 catch(const std::exception& e)
00820 {
00821 std::string str;
00822 str += "FC++ exception thrown (";
00823 str += e.what();
00824 str += ")";
00825 Base::Console().Error(str.c_str());
00826 PyErr_SetString(PyExc_Exception,str.c_str());
00827 return NULL;
00828 }
00829 catch(...)
00830 {
00831 PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00832 return NULL;
00833 }
00834 #endif
00835 }
00836
00837
00838
00839
00840 PyObject * DocumentPy::staticCallback_activeView (PyObject *self, PyObject *args)
00841 {
00842
00843 if (!((PyObjectBase*) self)->isValid()){
00844 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00845 return NULL;
00846 }
00847
00848
00849 if (((PyObjectBase*) self)->isConst()){
00850 PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00851 return NULL;
00852 }
00853
00854 try {
00855 PyObject* ret = ((DocumentPy*)self)->activeView(args);
00856 if (ret != 0)
00857 ((DocumentPy*)self)->startNotify();
00858 return ret;
00859 }
00860 catch(const Base::Exception& e)
00861 {
00862 std::string str;
00863 str += "FreeCAD exception thrown (";
00864 str += e.what();
00865 str += ")";
00866 e.ReportException();
00867 PyErr_SetString(PyExc_Exception,str.c_str());
00868 return NULL;
00869 }
00870 catch(const boost::filesystem::filesystem_error& e)
00871 {
00872 std::string str;
00873 str += "File system exception thrown (";
00874
00875
00876 str += e.what();
00877 str += ")\n";
00878 Base::Console().Error(str.c_str());
00879 PyErr_SetString(PyExc_Exception,str.c_str());
00880 return NULL;
00881 }
00882 catch(const Py::Exception&)
00883 {
00884
00885 return NULL;
00886 }
00887 catch(const char* e)
00888 {
00889 Base::Console().Error(e);
00890 PyErr_SetString(PyExc_Exception,e);
00891 return NULL;
00892 }
00893
00894 #ifndef DONT_CATCH_CXX_EXCEPTIONS
00895 catch(const std::exception& e)
00896 {
00897 std::string str;
00898 str += "FC++ exception thrown (";
00899 str += e.what();
00900 str += ")";
00901 Base::Console().Error(str.c_str());
00902 PyErr_SetString(PyExc_Exception,str.c_str());
00903 return NULL;
00904 }
00905 catch(...)
00906 {
00907 PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00908 return NULL;
00909 }
00910 #endif
00911 }
00912
00913
00914
00915
00916 PyObject * DocumentPy::staticCallback_getActiveObject (PyObject *self, void * )
00917 {
00918 if (!((PyObjectBase*) self)->isValid()){
00919 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00920 return NULL;
00921 }
00922
00923 try {
00924 return Py::new_reference_to(((DocumentPy*)self)->getActiveObject());
00925 } catch (const Py::Exception&) {
00926
00927 return NULL;
00928 } catch (...) {
00929 PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'ActiveObject' of object 'Document'");
00930 return NULL;
00931 }
00932 }
00933
00934 int DocumentPy::staticCallback_setActiveObject (PyObject *self, PyObject *value, void * )
00935 {
00936 if (!((PyObjectBase*) self)->isValid()){
00937 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00938 return -1;
00939 }
00940 if (((PyObjectBase*) self)->isConst()){
00941 PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
00942 return -1;
00943 }
00944
00945 try {
00946 ((DocumentPy*)self)->setActiveObject(Py::Object(value,false));
00947 return 0;
00948 } catch (const Py::Exception&) {
00949
00950 return -1;
00951 } catch (...) {
00952 PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'ActiveObject' of object 'Document'");
00953 return -1;
00954 }
00955 }
00956
00957
00958
00959
00960 PyObject * DocumentPy::staticCallback_getActiveView (PyObject *self, void * )
00961 {
00962 if (!((PyObjectBase*) self)->isValid()){
00963 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00964 return NULL;
00965 }
00966
00967 try {
00968 return Py::new_reference_to(((DocumentPy*)self)->getActiveView());
00969 } catch (const Py::Exception&) {
00970
00971 return NULL;
00972 } catch (...) {
00973 PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'ActiveView' of object 'Document'");
00974 return NULL;
00975 }
00976 }
00977
00978 int DocumentPy::staticCallback_setActiveView (PyObject *self, PyObject *value, void * )
00979 {
00980 if (!((PyObjectBase*) self)->isValid()){
00981 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00982 return -1;
00983 }
00984 if (((PyObjectBase*) self)->isConst()){
00985 PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
00986 return -1;
00987 }
00988
00989 try {
00990 ((DocumentPy*)self)->setActiveView(Py::Object(value,false));
00991 return 0;
00992 } catch (const Py::Exception&) {
00993
00994 return -1;
00995 } catch (...) {
00996 PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'ActiveView' of object 'Document'");
00997 return -1;
00998 }
00999 }
01000
01001
01002
01003
01004 PyObject * DocumentPy::staticCallback_getDocument (PyObject *self, void * )
01005 {
01006 if (!((PyObjectBase*) self)->isValid()){
01007 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01008 return NULL;
01009 }
01010
01011 try {
01012 return Py::new_reference_to(((DocumentPy*)self)->getDocument());
01013 } catch (const Py::Exception&) {
01014
01015 return NULL;
01016 } catch (...) {
01017 PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Document' of object 'Document'");
01018 return NULL;
01019 }
01020 }
01021
01022 int DocumentPy::staticCallback_setDocument (PyObject *self, PyObject * , void * )
01023 {
01024 if (!((PyObjectBase*) self)->isValid()){
01025 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
01026 return -1;
01027 }
01028
01029 PyErr_SetString(PyExc_AttributeError, "Attribute 'Document' of object 'Document' is read-only");
01030 return -1;
01031 }
01032
01033
01034
01035
01036
01037
01038 PyParentObject DocumentPy::Parents[] = { PARENTSGuiDocumentPy };
01039
01040
01041
01042
01043 DocumentPy::DocumentPy(Document *pcObject, PyTypeObject *T)
01044 : PersistencePy(reinterpret_cast<PersistencePy::PointerType>(pcObject), T)
01045 {
01046 }
01047
01048 PyObject *DocumentPy::PyMake(struct _typeobject *, PyObject *, PyObject *)
01049 {
01050
01051 PyErr_SetString(PyExc_RuntimeError, "You cannot create directly an instance of 'DocumentPy'.");
01052
01053 return 0;
01054 }
01055
01056 int DocumentPy::PyInit(PyObject* , PyObject* )
01057 {
01058 return 0;
01059 }
01060
01061
01062
01063
01064 DocumentPy::~DocumentPy()
01065 {
01066 }
01067
01068
01069
01070
01071 PyObject *DocumentPy::_repr(void)
01072 {
01073 return Py_BuildValue("s", representation().c_str());
01074 }
01075
01076
01077
01078
01079 PyObject *DocumentPy::_getattr(char *attr)
01080 {
01081 try {
01082
01083 PyObject *r = getCustomAttributes(attr);
01084 if(r) return r;
01085 }
01086 #ifndef DONT_CATCH_CXX_EXCEPTIONS
01087 catch(const Base::Exception& e)
01088 {
01089 std::string str;
01090 str += "FreeCAD exception thrown (";
01091 str += e.what();
01092 str += ")";
01093 e.ReportException();
01094 PyErr_SetString(PyExc_Exception,str.c_str());
01095 return NULL;
01096 }
01097 catch(const std::exception& e)
01098 {
01099 std::string str;
01100 str += "FC++ exception thrown (";
01101 str += e.what();
01102 str += ")";
01103 Base::Console().Error(str.c_str());
01104 PyErr_SetString(PyExc_Exception,str.c_str());
01105 return NULL;
01106 }
01107 catch(const Py::Exception&)
01108 {
01109
01110 return NULL;
01111 }
01112 catch(...)
01113 {
01114 PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
01115 return NULL;
01116 }
01117 #else // DONT_CATCH_CXX_EXCEPTIONS
01118 catch(const Base::Exception& e)
01119 {
01120 std::string str;
01121 str += "FreeCAD exception thrown (";
01122 str += e.what();
01123 str += ")";
01124 e.ReportException();
01125 PyErr_SetString(PyExc_Exception,str.c_str());
01126 return NULL;
01127 }
01128 catch(const Py::Exception&)
01129 {
01130
01131 return NULL;
01132 }
01133 #endif // DONT_CATCH_CXX_EXCEPTIONS
01134
01135 PyObject *rvalue = Py_FindMethod(Methods, this, attr);
01136 if (rvalue == NULL)
01137 {
01138 PyErr_Clear();
01139 return PersistencePy::_getattr(attr);
01140 }
01141 else
01142 {
01143 return rvalue;
01144 }
01145 }
01146
01147 int DocumentPy::_setattr(char *attr, PyObject *value)
01148 {
01149 try {
01150
01151 int r = setCustomAttributes(attr, value);
01152 if(r==1) return 0;
01153 }
01154 #ifndef DONT_CATCH_CXX_EXCEPTIONS
01155 catch(const Base::Exception& e)
01156 {
01157 std::string str;
01158 str += "FreeCAD exception thrown (";
01159 str += e.what();
01160 str += ")";
01161 e.ReportException();
01162 PyErr_SetString(PyExc_Exception,str.c_str());
01163 return -1;
01164 }
01165 catch(const std::exception& e)
01166 {
01167 std::string str;
01168 str += "FC++ exception thrown (";
01169 str += e.what();
01170 str += ")";
01171 Base::Console().Error(str.c_str());
01172 PyErr_SetString(PyExc_Exception,str.c_str());
01173 return -1;
01174 }
01175 catch(const Py::Exception&)
01176 {
01177
01178 return -1;
01179 }
01180 catch(...)
01181 {
01182 PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
01183 return -1;
01184 }
01185 #else // DONT_CATCH_CXX_EXCEPTIONS
01186 catch(const Base::Exception& e)
01187 {
01188 std::string str;
01189 str += "FreeCAD exception thrown (";
01190 str += e.what();
01191 str += ")";
01192 e.ReportException();
01193 PyErr_SetString(PyExc_Exception,str.c_str());
01194 return -1;
01195 }
01196 catch(const Py::Exception&)
01197 {
01198
01199 return -1;
01200 }
01201 #endif // DONT_CATCH_CXX_EXCEPTIONS
01202
01203 return PersistencePy::_setattr(attr, value);
01204 }
01205
01206 Document *DocumentPy::getDocumentPtr(void) const
01207 {
01208 return static_cast<Document *>(_pcTwinPointer);
01209 }
01210
01211 #if 0
01212
01213
01214
01215
01216
01217
01218 std::string DocumentPy::representation(void) const
01219 {
01220 return std::string("<Document object>");
01221 }
01222
01223 PyObject* DocumentPy::show(PyObject *args)
01224 {
01225 PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01226 return 0;
01227 }
01228
01229 PyObject* DocumentPy::hide(PyObject *args)
01230 {
01231 PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01232 return 0;
01233 }
01234
01235 PyObject* DocumentPy::setPos(PyObject *args)
01236 {
01237 PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01238 return 0;
01239 }
01240
01241 PyObject* DocumentPy::setEdit(PyObject *args)
01242 {
01243 PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01244 return 0;
01245 }
01246
01247 PyObject* DocumentPy::resetEdit(PyObject *args)
01248 {
01249 PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01250 return 0;
01251 }
01252
01253 PyObject* DocumentPy::addAnnotation(PyObject *args)
01254 {
01255 PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01256 return 0;
01257 }
01258
01259 PyObject* DocumentPy::update(PyObject *args)
01260 {
01261 PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01262 return 0;
01263 }
01264
01265 PyObject* DocumentPy::getObject(PyObject *args)
01266 {
01267 PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01268 return 0;
01269 }
01270
01271 PyObject* DocumentPy::activeObject(PyObject *args)
01272 {
01273 PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01274 return 0;
01275 }
01276
01277 PyObject* DocumentPy::activeView(PyObject *args)
01278 {
01279 PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01280 return 0;
01281 }
01282
01283
01284
01285 Py::Object DocumentPy::getActiveObject(void) const
01286 {
01287
01288 throw Py::AttributeError("Not yet implemented");
01289 }
01290
01291 void DocumentPy::setActiveObject(Py::Object arg)
01292 {
01293 throw Py::AttributeError("Not yet implemented");
01294 }
01295
01296 Py::Object DocumentPy::getActiveView(void) const
01297 {
01298
01299 throw Py::AttributeError("Not yet implemented");
01300 }
01301
01302 void DocumentPy::setActiveView(Py::Object arg)
01303 {
01304 throw Py::AttributeError("Not yet implemented");
01305 }
01306
01307 Py::Object DocumentPy::getDocument(void) const
01308 {
01309
01310 throw Py::AttributeError("Not yet implemented");
01311 }
01312
01313 PyObject *DocumentPy::getCustomAttributes(const char* attr) const
01314 {
01315 return 0;
01316 }
01317
01318 int DocumentPy::setCustomAttributes(const char* attr, PyObject *obj)
01319 {
01320 return 0;
01321 }
01322 #endif
01323
01324
01325