ViewProviderPy.cpp

Go to the documentation of this file.
00001 
00002 // This file is generated by src/Tools/generateTemaplates/templateClassPyExport.py out of the .XML file
00003 // Every change you make here get lost at the next full rebuild!
00004 // This File is normaly build as an include in ViewProviderPyImp.cpp! Its not intended to be in a project!
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 ViewProviderPy::Type = {
00021     PyObject_HEAD_INIT(&PyType_Type)
00022     0,                                                /*ob_size*/
00023     "Gui.ViewProvider",     /*tp_name*/
00024     sizeof(ViewProviderPy),                       /*tp_basicsize*/
00025     0,                                                /*tp_itemsize*/
00026     /* methods */
00027     PyDestructor,                                     /*tp_dealloc*/
00028     0,                                                /*tp_print*/
00029     __getattr,                                        /*tp_getattr*/
00030     __setattr,                                        /*tp_setattr*/
00031     0,                                                /*tp_compare*/
00032     __repr,                                           /*tp_repr*/
00033     0,                                                /*tp_as_number*/
00034     0,                                                /*tp_as_sequence*/
00035     0,                                                /*tp_as_mapping*/
00036     0,                                                /*tp_hash*/
00037     0,                                                /*tp_call */
00038     0,                                                /*tp_str  */
00039     0,                                                /*tp_getattro*/
00040     0,                                                /*tp_setattro*/
00041     /* --- Functions to access object as input/output buffer ---------*/
00042     0,                                                /* tp_as_buffer */
00043     /* --- Flags to define presence of optional/expanded features */
00044     Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_CLASS,        /*tp_flags */
00045     "This is the ViewProvider base class",           /*tp_doc */
00046     0,                                                /*tp_traverse */
00047     0,                                                /*tp_clear */
00048     0,                                                /*tp_richcompare */
00049     0,                                                /*tp_weaklistoffset */
00050     0,                                                /*tp_iter */
00051     0,                                                /*tp_iternext */
00052     Gui::ViewProviderPy::Methods,                     /*tp_methods */
00053     0,                                                /*tp_members */
00054     Gui::ViewProviderPy::GetterSetter,                     /*tp_getset */
00055     &App::PropertyContainerPy::Type,                        /*tp_base */
00056     0,                                                /*tp_dict */
00057     0,                                                /*tp_descr_get */
00058     0,                                                /*tp_descr_set */
00059     0,                                                /*tp_dictoffset */
00060     __PyInit,                                         /*tp_init */
00061     0,                                                /*tp_alloc */
00062     Gui::ViewProviderPy::PyMake,/*tp_new */
00063     0,                                                /*tp_free   Low-level free-memory routine */
00064     0,                                                /*tp_is_gc  For PyObject_IS_GC */
00065     0,                                                /*tp_bases */
00066     0,                                                /*tp_mro    method resolution order */
00067     0,                                                /*tp_cache */
00068     0,                                                /*tp_subclasses */
00069     0,                                                /*tp_weaklist */
00070     0                                                 /*tp_del */
00071 };
00072 
00074 PyMethodDef ViewProviderPy::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     {"isVisible",
00086         (PyCFunction) staticCallback_isVisible,
00087         METH_VARARGS,
00088         "Check if the object is visible"
00089     },
00090     {"listDisplayModes",
00091         (PyCFunction) staticCallback_listDisplayModes,
00092         METH_VARARGS,
00093         "Show a list of all display modes"
00094     },
00095     {"toString",
00096         (PyCFunction) staticCallback_toString,
00097         METH_VARARGS,
00098         "Return a string representation of the Inventor node"
00099     },
00100     {"startEditing",
00101         (PyCFunction) staticCallback_startEditing,
00102         METH_VARARGS,
00103         "Start the editing mode (default=0)"
00104     },
00105     {"finishEditing",
00106         (PyCFunction) staticCallback_finishEditing,
00107         METH_VARARGS,
00108         "Finish editing mode"
00109     },
00110     {"isEditing",
00111         (PyCFunction) staticCallback_isEditing,
00112         METH_VARARGS,
00113         "Returns True if the view provider is in editing mode, False otherwise"
00114     },
00115     {"setTransformation",
00116         (PyCFunction) staticCallback_setTransformation,
00117         METH_VARARGS,
00118         "Set a transformation on the Inventor node"
00119     },
00120     {NULL, NULL, 0, NULL}               /* Sentinel */
00121 };
00122 
00123 
00124 
00126 PyGetSetDef ViewProviderPy::GetterSetter[] = {
00127     {"Annotation",
00128         (getter) staticCallback_getAnnotation,
00129         (setter) staticCallback_setAnnotation, 
00130         "A pivy Separator to add a custom scene graph to this ViewProvider",
00131         NULL
00132     },
00133     {"RootNode",
00134         (getter) staticCallback_getRootNode,
00135         (setter) staticCallback_setRootNode, 
00136         "A pivy Separator with the root of this ViewProvider",
00137         NULL
00138     },
00139     {"IV",
00140         (getter) staticCallback_getIV,
00141         (setter) staticCallback_setIV, 
00142         "Represents the whole ViewProvider as an Inventor string.",
00143         NULL
00144     },
00145     {NULL, NULL, NULL, NULL, NULL}              /* Sentinel */
00146 };
00147 
00148 // show() callback and implementer
00149 // PyObject*  ViewProviderPy::show(PyObject *args){};
00150 // has to be implemented in ViewProviderPyImp.cpp
00151 PyObject * ViewProviderPy::staticCallback_show (PyObject *self, PyObject *args)
00152 {
00153     // test if twin object not allready deleted
00154     if (!((PyObjectBase*) self)->isValid()){
00155         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00156         return NULL;
00157     }
00158 
00159     // test if object is set Const
00160     if (((PyObjectBase*) self)->isConst()){
00161         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00162         return NULL;
00163     }
00164 
00165     try { // catches all exceptions coming up from c++ and generate a python exception
00166         PyObject* ret = ((ViewProviderPy*)self)->show(args);
00167         if (ret != 0)
00168             ((ViewProviderPy*)self)->startNotify();
00169         return ret;
00170     }
00171     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00172     {
00173         std::string str;
00174         str += "FreeCAD exception thrown (";
00175         str += e.what();
00176         str += ")";
00177         e.ReportException();
00178         PyErr_SetString(PyExc_Exception,str.c_str());
00179         return NULL;
00180     }
00181     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00182     {
00183         std::string str;
00184         str += "File system exception thrown (";
00185         //str += e.who();
00186         //str += ", ";
00187         str += e.what();
00188         str += ")\n";
00189         Base::Console().Error(str.c_str());
00190         PyErr_SetString(PyExc_Exception,str.c_str());
00191         return NULL;
00192     }
00193     catch(const Py::Exception&)
00194     {
00195         // The exception text is already set
00196         return NULL;
00197     }
00198     catch(const char* e) // catch simple string exceptions
00199     {
00200         Base::Console().Error(e);
00201         PyErr_SetString(PyExc_Exception,e);
00202         return NULL;
00203     }
00204     // in debug not all exceptions will be catched to get the attention of the developer!
00205 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00206     catch(const std::exception& e) // catch other c++ exceptions
00207     {
00208         std::string str;
00209         str += "FC++ exception thrown (";
00210         str += e.what();
00211         str += ")";
00212         Base::Console().Error(str.c_str());
00213         PyErr_SetString(PyExc_Exception,str.c_str());
00214         return NULL;
00215     }
00216     catch(...)  // catch the rest!
00217     {
00218         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00219         return NULL;
00220     }
00221 #endif
00222 }
00223 
00224 // hide() callback and implementer
00225 // PyObject*  ViewProviderPy::hide(PyObject *args){};
00226 // has to be implemented in ViewProviderPyImp.cpp
00227 PyObject * ViewProviderPy::staticCallback_hide (PyObject *self, PyObject *args)
00228 {
00229     // test if twin object not allready deleted
00230     if (!((PyObjectBase*) self)->isValid()){
00231         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00232         return NULL;
00233     }
00234 
00235     // test if object is set Const
00236     if (((PyObjectBase*) self)->isConst()){
00237         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00238         return NULL;
00239     }
00240 
00241     try { // catches all exceptions coming up from c++ and generate a python exception
00242         PyObject* ret = ((ViewProviderPy*)self)->hide(args);
00243         if (ret != 0)
00244             ((ViewProviderPy*)self)->startNotify();
00245         return ret;
00246     }
00247     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00248     {
00249         std::string str;
00250         str += "FreeCAD exception thrown (";
00251         str += e.what();
00252         str += ")";
00253         e.ReportException();
00254         PyErr_SetString(PyExc_Exception,str.c_str());
00255         return NULL;
00256     }
00257     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00258     {
00259         std::string str;
00260         str += "File system exception thrown (";
00261         //str += e.who();
00262         //str += ", ";
00263         str += e.what();
00264         str += ")\n";
00265         Base::Console().Error(str.c_str());
00266         PyErr_SetString(PyExc_Exception,str.c_str());
00267         return NULL;
00268     }
00269     catch(const Py::Exception&)
00270     {
00271         // The exception text is already set
00272         return NULL;
00273     }
00274     catch(const char* e) // catch simple string exceptions
00275     {
00276         Base::Console().Error(e);
00277         PyErr_SetString(PyExc_Exception,e);
00278         return NULL;
00279     }
00280     // in debug not all exceptions will be catched to get the attention of the developer!
00281 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00282     catch(const std::exception& e) // catch other c++ exceptions
00283     {
00284         std::string str;
00285         str += "FC++ exception thrown (";
00286         str += e.what();
00287         str += ")";
00288         Base::Console().Error(str.c_str());
00289         PyErr_SetString(PyExc_Exception,str.c_str());
00290         return NULL;
00291     }
00292     catch(...)  // catch the rest!
00293     {
00294         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00295         return NULL;
00296     }
00297 #endif
00298 }
00299 
00300 // isVisible() callback and implementer
00301 // PyObject*  ViewProviderPy::isVisible(PyObject *args){};
00302 // has to be implemented in ViewProviderPyImp.cpp
00303 PyObject * ViewProviderPy::staticCallback_isVisible (PyObject *self, PyObject *args)
00304 {
00305     // test if twin object not allready deleted
00306     if (!((PyObjectBase*) self)->isValid()){
00307         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00308         return NULL;
00309     }
00310 
00311     // test if object is set Const
00312     if (((PyObjectBase*) self)->isConst()){
00313         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00314         return NULL;
00315     }
00316 
00317     try { // catches all exceptions coming up from c++ and generate a python exception
00318         PyObject* ret = ((ViewProviderPy*)self)->isVisible(args);
00319         if (ret != 0)
00320             ((ViewProviderPy*)self)->startNotify();
00321         return ret;
00322     }
00323     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00324     {
00325         std::string str;
00326         str += "FreeCAD exception thrown (";
00327         str += e.what();
00328         str += ")";
00329         e.ReportException();
00330         PyErr_SetString(PyExc_Exception,str.c_str());
00331         return NULL;
00332     }
00333     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00334     {
00335         std::string str;
00336         str += "File system exception thrown (";
00337         //str += e.who();
00338         //str += ", ";
00339         str += e.what();
00340         str += ")\n";
00341         Base::Console().Error(str.c_str());
00342         PyErr_SetString(PyExc_Exception,str.c_str());
00343         return NULL;
00344     }
00345     catch(const Py::Exception&)
00346     {
00347         // The exception text is already set
00348         return NULL;
00349     }
00350     catch(const char* e) // catch simple string exceptions
00351     {
00352         Base::Console().Error(e);
00353         PyErr_SetString(PyExc_Exception,e);
00354         return NULL;
00355     }
00356     // in debug not all exceptions will be catched to get the attention of the developer!
00357 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00358     catch(const std::exception& e) // catch other c++ exceptions
00359     {
00360         std::string str;
00361         str += "FC++ exception thrown (";
00362         str += e.what();
00363         str += ")";
00364         Base::Console().Error(str.c_str());
00365         PyErr_SetString(PyExc_Exception,str.c_str());
00366         return NULL;
00367     }
00368     catch(...)  // catch the rest!
00369     {
00370         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00371         return NULL;
00372     }
00373 #endif
00374 }
00375 
00376 // listDisplayModes() callback and implementer
00377 // PyObject*  ViewProviderPy::listDisplayModes(PyObject *args){};
00378 // has to be implemented in ViewProviderPyImp.cpp
00379 PyObject * ViewProviderPy::staticCallback_listDisplayModes (PyObject *self, PyObject *args)
00380 {
00381     // test if twin object not allready deleted
00382     if (!((PyObjectBase*) self)->isValid()){
00383         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00384         return NULL;
00385     }
00386 
00387     // test if object is set Const
00388     if (((PyObjectBase*) self)->isConst()){
00389         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00390         return NULL;
00391     }
00392 
00393     try { // catches all exceptions coming up from c++ and generate a python exception
00394         PyObject* ret = ((ViewProviderPy*)self)->listDisplayModes(args);
00395         if (ret != 0)
00396             ((ViewProviderPy*)self)->startNotify();
00397         return ret;
00398     }
00399     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00400     {
00401         std::string str;
00402         str += "FreeCAD exception thrown (";
00403         str += e.what();
00404         str += ")";
00405         e.ReportException();
00406         PyErr_SetString(PyExc_Exception,str.c_str());
00407         return NULL;
00408     }
00409     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00410     {
00411         std::string str;
00412         str += "File system exception thrown (";
00413         //str += e.who();
00414         //str += ", ";
00415         str += e.what();
00416         str += ")\n";
00417         Base::Console().Error(str.c_str());
00418         PyErr_SetString(PyExc_Exception,str.c_str());
00419         return NULL;
00420     }
00421     catch(const Py::Exception&)
00422     {
00423         // The exception text is already set
00424         return NULL;
00425     }
00426     catch(const char* e) // catch simple string exceptions
00427     {
00428         Base::Console().Error(e);
00429         PyErr_SetString(PyExc_Exception,e);
00430         return NULL;
00431     }
00432     // in debug not all exceptions will be catched to get the attention of the developer!
00433 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00434     catch(const std::exception& e) // catch other c++ exceptions
00435     {
00436         std::string str;
00437         str += "FC++ exception thrown (";
00438         str += e.what();
00439         str += ")";
00440         Base::Console().Error(str.c_str());
00441         PyErr_SetString(PyExc_Exception,str.c_str());
00442         return NULL;
00443     }
00444     catch(...)  // catch the rest!
00445     {
00446         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00447         return NULL;
00448     }
00449 #endif
00450 }
00451 
00452 // toString() callback and implementer
00453 // PyObject*  ViewProviderPy::toString(PyObject *args){};
00454 // has to be implemented in ViewProviderPyImp.cpp
00455 PyObject * ViewProviderPy::staticCallback_toString (PyObject *self, PyObject *args)
00456 {
00457     // test if twin object not allready deleted
00458     if (!((PyObjectBase*) self)->isValid()){
00459         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00460         return NULL;
00461     }
00462 
00463     // test if object is set Const
00464     if (((PyObjectBase*) self)->isConst()){
00465         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00466         return NULL;
00467     }
00468 
00469     try { // catches all exceptions coming up from c++ and generate a python exception
00470         PyObject* ret = ((ViewProviderPy*)self)->toString(args);
00471         if (ret != 0)
00472             ((ViewProviderPy*)self)->startNotify();
00473         return ret;
00474     }
00475     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00476     {
00477         std::string str;
00478         str += "FreeCAD exception thrown (";
00479         str += e.what();
00480         str += ")";
00481         e.ReportException();
00482         PyErr_SetString(PyExc_Exception,str.c_str());
00483         return NULL;
00484     }
00485     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00486     {
00487         std::string str;
00488         str += "File system exception thrown (";
00489         //str += e.who();
00490         //str += ", ";
00491         str += e.what();
00492         str += ")\n";
00493         Base::Console().Error(str.c_str());
00494         PyErr_SetString(PyExc_Exception,str.c_str());
00495         return NULL;
00496     }
00497     catch(const Py::Exception&)
00498     {
00499         // The exception text is already set
00500         return NULL;
00501     }
00502     catch(const char* e) // catch simple string exceptions
00503     {
00504         Base::Console().Error(e);
00505         PyErr_SetString(PyExc_Exception,e);
00506         return NULL;
00507     }
00508     // in debug not all exceptions will be catched to get the attention of the developer!
00509 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00510     catch(const std::exception& e) // catch other c++ exceptions
00511     {
00512         std::string str;
00513         str += "FC++ exception thrown (";
00514         str += e.what();
00515         str += ")";
00516         Base::Console().Error(str.c_str());
00517         PyErr_SetString(PyExc_Exception,str.c_str());
00518         return NULL;
00519     }
00520     catch(...)  // catch the rest!
00521     {
00522         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00523         return NULL;
00524     }
00525 #endif
00526 }
00527 
00528 // startEditing() callback and implementer
00529 // PyObject*  ViewProviderPy::startEditing(PyObject *args){};
00530 // has to be implemented in ViewProviderPyImp.cpp
00531 PyObject * ViewProviderPy::staticCallback_startEditing (PyObject *self, PyObject *args)
00532 {
00533     // test if twin object not allready deleted
00534     if (!((PyObjectBase*) self)->isValid()){
00535         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00536         return NULL;
00537     }
00538 
00539     // test if object is set Const
00540     if (((PyObjectBase*) self)->isConst()){
00541         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00542         return NULL;
00543     }
00544 
00545     try { // catches all exceptions coming up from c++ and generate a python exception
00546         PyObject* ret = ((ViewProviderPy*)self)->startEditing(args);
00547         if (ret != 0)
00548             ((ViewProviderPy*)self)->startNotify();
00549         return ret;
00550     }
00551     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00552     {
00553         std::string str;
00554         str += "FreeCAD exception thrown (";
00555         str += e.what();
00556         str += ")";
00557         e.ReportException();
00558         PyErr_SetString(PyExc_Exception,str.c_str());
00559         return NULL;
00560     }
00561     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00562     {
00563         std::string str;
00564         str += "File system exception thrown (";
00565         //str += e.who();
00566         //str += ", ";
00567         str += e.what();
00568         str += ")\n";
00569         Base::Console().Error(str.c_str());
00570         PyErr_SetString(PyExc_Exception,str.c_str());
00571         return NULL;
00572     }
00573     catch(const Py::Exception&)
00574     {
00575         // The exception text is already set
00576         return NULL;
00577     }
00578     catch(const char* e) // catch simple string exceptions
00579     {
00580         Base::Console().Error(e);
00581         PyErr_SetString(PyExc_Exception,e);
00582         return NULL;
00583     }
00584     // in debug not all exceptions will be catched to get the attention of the developer!
00585 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00586     catch(const std::exception& e) // catch other c++ exceptions
00587     {
00588         std::string str;
00589         str += "FC++ exception thrown (";
00590         str += e.what();
00591         str += ")";
00592         Base::Console().Error(str.c_str());
00593         PyErr_SetString(PyExc_Exception,str.c_str());
00594         return NULL;
00595     }
00596     catch(...)  // catch the rest!
00597     {
00598         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00599         return NULL;
00600     }
00601 #endif
00602 }
00603 
00604 // finishEditing() callback and implementer
00605 // PyObject*  ViewProviderPy::finishEditing(PyObject *args){};
00606 // has to be implemented in ViewProviderPyImp.cpp
00607 PyObject * ViewProviderPy::staticCallback_finishEditing (PyObject *self, PyObject *args)
00608 {
00609     // test if twin object not allready deleted
00610     if (!((PyObjectBase*) self)->isValid()){
00611         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00612         return NULL;
00613     }
00614 
00615     // test if object is set Const
00616     if (((PyObjectBase*) self)->isConst()){
00617         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00618         return NULL;
00619     }
00620 
00621     try { // catches all exceptions coming up from c++ and generate a python exception
00622         PyObject* ret = ((ViewProviderPy*)self)->finishEditing(args);
00623         if (ret != 0)
00624             ((ViewProviderPy*)self)->startNotify();
00625         return ret;
00626     }
00627     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00628     {
00629         std::string str;
00630         str += "FreeCAD exception thrown (";
00631         str += e.what();
00632         str += ")";
00633         e.ReportException();
00634         PyErr_SetString(PyExc_Exception,str.c_str());
00635         return NULL;
00636     }
00637     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00638     {
00639         std::string str;
00640         str += "File system exception thrown (";
00641         //str += e.who();
00642         //str += ", ";
00643         str += e.what();
00644         str += ")\n";
00645         Base::Console().Error(str.c_str());
00646         PyErr_SetString(PyExc_Exception,str.c_str());
00647         return NULL;
00648     }
00649     catch(const Py::Exception&)
00650     {
00651         // The exception text is already set
00652         return NULL;
00653     }
00654     catch(const char* e) // catch simple string exceptions
00655     {
00656         Base::Console().Error(e);
00657         PyErr_SetString(PyExc_Exception,e);
00658         return NULL;
00659     }
00660     // in debug not all exceptions will be catched to get the attention of the developer!
00661 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00662     catch(const std::exception& e) // catch other c++ exceptions
00663     {
00664         std::string str;
00665         str += "FC++ exception thrown (";
00666         str += e.what();
00667         str += ")";
00668         Base::Console().Error(str.c_str());
00669         PyErr_SetString(PyExc_Exception,str.c_str());
00670         return NULL;
00671     }
00672     catch(...)  // catch the rest!
00673     {
00674         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00675         return NULL;
00676     }
00677 #endif
00678 }
00679 
00680 // isEditing() callback and implementer
00681 // PyObject*  ViewProviderPy::isEditing(PyObject *args){};
00682 // has to be implemented in ViewProviderPyImp.cpp
00683 PyObject * ViewProviderPy::staticCallback_isEditing (PyObject *self, PyObject *args)
00684 {
00685     // test if twin object not allready deleted
00686     if (!((PyObjectBase*) self)->isValid()){
00687         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00688         return NULL;
00689     }
00690 
00691     // test if object is set Const
00692     if (((PyObjectBase*) self)->isConst()){
00693         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00694         return NULL;
00695     }
00696 
00697     try { // catches all exceptions coming up from c++ and generate a python exception
00698         PyObject* ret = ((ViewProviderPy*)self)->isEditing(args);
00699         if (ret != 0)
00700             ((ViewProviderPy*)self)->startNotify();
00701         return ret;
00702     }
00703     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00704     {
00705         std::string str;
00706         str += "FreeCAD exception thrown (";
00707         str += e.what();
00708         str += ")";
00709         e.ReportException();
00710         PyErr_SetString(PyExc_Exception,str.c_str());
00711         return NULL;
00712     }
00713     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00714     {
00715         std::string str;
00716         str += "File system exception thrown (";
00717         //str += e.who();
00718         //str += ", ";
00719         str += e.what();
00720         str += ")\n";
00721         Base::Console().Error(str.c_str());
00722         PyErr_SetString(PyExc_Exception,str.c_str());
00723         return NULL;
00724     }
00725     catch(const Py::Exception&)
00726     {
00727         // The exception text is already set
00728         return NULL;
00729     }
00730     catch(const char* e) // catch simple string exceptions
00731     {
00732         Base::Console().Error(e);
00733         PyErr_SetString(PyExc_Exception,e);
00734         return NULL;
00735     }
00736     // in debug not all exceptions will be catched to get the attention of the developer!
00737 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00738     catch(const std::exception& e) // catch other c++ exceptions
00739     {
00740         std::string str;
00741         str += "FC++ exception thrown (";
00742         str += e.what();
00743         str += ")";
00744         Base::Console().Error(str.c_str());
00745         PyErr_SetString(PyExc_Exception,str.c_str());
00746         return NULL;
00747     }
00748     catch(...)  // catch the rest!
00749     {
00750         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00751         return NULL;
00752     }
00753 #endif
00754 }
00755 
00756 // setTransformation() callback and implementer
00757 // PyObject*  ViewProviderPy::setTransformation(PyObject *args){};
00758 // has to be implemented in ViewProviderPyImp.cpp
00759 PyObject * ViewProviderPy::staticCallback_setTransformation (PyObject *self, PyObject *args)
00760 {
00761     // test if twin object not allready deleted
00762     if (!((PyObjectBase*) self)->isValid()){
00763         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00764         return NULL;
00765     }
00766 
00767     // test if object is set Const
00768     if (((PyObjectBase*) self)->isConst()){
00769         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00770         return NULL;
00771     }
00772 
00773     try { // catches all exceptions coming up from c++ and generate a python exception
00774         PyObject* ret = ((ViewProviderPy*)self)->setTransformation(args);
00775         if (ret != 0)
00776             ((ViewProviderPy*)self)->startNotify();
00777         return ret;
00778     }
00779     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00780     {
00781         std::string str;
00782         str += "FreeCAD exception thrown (";
00783         str += e.what();
00784         str += ")";
00785         e.ReportException();
00786         PyErr_SetString(PyExc_Exception,str.c_str());
00787         return NULL;
00788     }
00789     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00790     {
00791         std::string str;
00792         str += "File system exception thrown (";
00793         //str += e.who();
00794         //str += ", ";
00795         str += e.what();
00796         str += ")\n";
00797         Base::Console().Error(str.c_str());
00798         PyErr_SetString(PyExc_Exception,str.c_str());
00799         return NULL;
00800     }
00801     catch(const Py::Exception&)
00802     {
00803         // The exception text is already set
00804         return NULL;
00805     }
00806     catch(const char* e) // catch simple string exceptions
00807     {
00808         Base::Console().Error(e);
00809         PyErr_SetString(PyExc_Exception,e);
00810         return NULL;
00811     }
00812     // in debug not all exceptions will be catched to get the attention of the developer!
00813 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00814     catch(const std::exception& e) // catch other c++ exceptions
00815     {
00816         std::string str;
00817         str += "FC++ exception thrown (";
00818         str += e.what();
00819         str += ")";
00820         Base::Console().Error(str.c_str());
00821         PyErr_SetString(PyExc_Exception,str.c_str());
00822         return NULL;
00823     }
00824     catch(...)  // catch the rest!
00825     {
00826         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00827         return NULL;
00828     }
00829 #endif
00830 }
00831 
00832 // Annotation() callback and implementer
00833 // PyObject*  ViewProviderPy::Annotation(PyObject *args){};
00834 // has to be implemented in ViewProviderPyImp.cpp
00835 PyObject * ViewProviderPy::staticCallback_getAnnotation (PyObject *self, void * /*closure*/)
00836 {
00837     if (!((PyObjectBase*) self)->isValid()){
00838         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00839         return NULL;
00840     }
00841 
00842     try {
00843         return Py::new_reference_to(((ViewProviderPy*)self)->getAnnotation());
00844     } catch (const Py::Exception&) {
00845         // The exception text is already set
00846         return NULL;
00847     } catch (...) {
00848         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Annotation' of object 'ViewProvider'");
00849         return NULL;
00850     }
00851 }
00852 
00853 int ViewProviderPy::staticCallback_setAnnotation (PyObject *self, PyObject *value, void * /*closure*/)
00854 {    
00855     if (!((PyObjectBase*) self)->isValid()){
00856         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00857         return -1;
00858     }
00859     if (((PyObjectBase*) self)->isConst()){
00860         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
00861         return -1;
00862     }
00863 
00864     try {
00865         ((ViewProviderPy*)self)->setAnnotation(Py::Object(value,false));
00866         return 0;
00867     } catch (const Py::Exception&) {
00868         // The exception text is already set
00869         return -1;
00870     } catch (...) {
00871         PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'Annotation' of object 'ViewProvider'");
00872         return -1;
00873     }
00874 }
00875 
00876 // RootNode() callback and implementer
00877 // PyObject*  ViewProviderPy::RootNode(PyObject *args){};
00878 // has to be implemented in ViewProviderPyImp.cpp
00879 PyObject * ViewProviderPy::staticCallback_getRootNode (PyObject *self, void * /*closure*/)
00880 {
00881     if (!((PyObjectBase*) self)->isValid()){
00882         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00883         return NULL;
00884     }
00885 
00886     try {
00887         return Py::new_reference_to(((ViewProviderPy*)self)->getRootNode());
00888     } catch (const Py::Exception&) {
00889         // The exception text is already set
00890         return NULL;
00891     } catch (...) {
00892         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'RootNode' of object 'ViewProvider'");
00893         return NULL;
00894     }
00895 }
00896 
00897 int ViewProviderPy::staticCallback_setRootNode (PyObject *self, PyObject *value, void * /*closure*/)
00898 {    
00899     if (!((PyObjectBase*) self)->isValid()){
00900         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00901         return -1;
00902     }
00903     if (((PyObjectBase*) self)->isConst()){
00904         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
00905         return -1;
00906     }
00907 
00908     try {
00909         ((ViewProviderPy*)self)->setRootNode(Py::Object(value,false));
00910         return 0;
00911     } catch (const Py::Exception&) {
00912         // The exception text is already set
00913         return -1;
00914     } catch (...) {
00915         PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'RootNode' of object 'ViewProvider'");
00916         return -1;
00917     }
00918 }
00919 
00920 // IV() callback and implementer
00921 // PyObject*  ViewProviderPy::IV(PyObject *args){};
00922 // has to be implemented in ViewProviderPyImp.cpp
00923 PyObject * ViewProviderPy::staticCallback_getIV (PyObject *self, void * /*closure*/)
00924 {
00925     if (!((PyObjectBase*) self)->isValid()){
00926         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00927         return NULL;
00928     }
00929 
00930     try {
00931         return Py::new_reference_to(((ViewProviderPy*)self)->getIV());
00932     } catch (const Py::Exception&) {
00933         // The exception text is already set
00934         return NULL;
00935     } catch (...) {
00936         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'IV' of object 'ViewProvider'");
00937         return NULL;
00938     }
00939 }
00940 
00941 int ViewProviderPy::staticCallback_setIV (PyObject *self, PyObject * /*value*/, void * /*closure*/)
00942 {
00943     if (!((PyObjectBase*) self)->isValid()){
00944         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00945         return -1;
00946     }
00947 
00948     PyErr_SetString(PyExc_AttributeError, "Attribute 'IV' of object 'ViewProvider' is read-only");
00949     return -1;
00950 }
00951 
00952 
00953 
00954 //--------------------------------------------------------------------------
00955 // Parents structure
00956 //--------------------------------------------------------------------------
00957 PyParentObject ViewProviderPy::Parents[] = { PARENTSGuiViewProviderPy };
00958 
00959 //--------------------------------------------------------------------------
00960 // Constructor
00961 //--------------------------------------------------------------------------
00962 ViewProviderPy::ViewProviderPy(ViewProvider *pcObject, PyTypeObject *T)
00963     : PropertyContainerPy(reinterpret_cast<PropertyContainerPy::PointerType>(pcObject), T)
00964 {
00965 }
00966 
00967 PyObject *ViewProviderPy::PyMake(struct _typeobject *, PyObject *, PyObject *)  // Python wrapper
00968 {
00969     // never create such objects with the constructor
00970     PyErr_SetString(PyExc_RuntimeError, "You cannot create directly an instance of 'ViewProviderPy'.");
00971  
00972     return 0;
00973 }
00974 
00975 int ViewProviderPy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
00976 {
00977     return 0;
00978 }
00979 
00980 //--------------------------------------------------------------------------
00981 // destructor
00982 //--------------------------------------------------------------------------
00983 ViewProviderPy::~ViewProviderPy()                                // Everything handled in parent
00984 {
00985 }
00986 
00987 //--------------------------------------------------------------------------
00988 // ViewProviderPy representation
00989 //--------------------------------------------------------------------------
00990 PyObject *ViewProviderPy::_repr(void)
00991 {
00992     return Py_BuildValue("s", representation().c_str());
00993 }
00994 
00995 //--------------------------------------------------------------------------
00996 // ViewProviderPy Attributes
00997 //--------------------------------------------------------------------------
00998 PyObject *ViewProviderPy::_getattr(char *attr)                          // __getattr__ function: note only need to handle new state
00999 {
01000     try {
01001         // getter method for special Attributes (e.g. dynamic ones)
01002         PyObject *r = getCustomAttributes(attr);
01003         if(r) return r;
01004     }
01005 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
01006     catch(const Base::Exception& e) // catch the FreeCAD exceptions
01007     {
01008         std::string str;
01009         str += "FreeCAD exception thrown (";
01010         str += e.what();
01011         str += ")";
01012         e.ReportException();
01013         PyErr_SetString(PyExc_Exception,str.c_str());
01014         return NULL;
01015     }
01016     catch(const std::exception& e) // catch other c++ exceptions
01017     {
01018         std::string str;
01019         str += "FC++ exception thrown (";
01020         str += e.what();
01021         str += ")";
01022         Base::Console().Error(str.c_str());
01023         PyErr_SetString(PyExc_Exception,str.c_str());
01024         return NULL;
01025     }
01026     catch(const Py::Exception&)
01027     {
01028         // The exception text is already set
01029         return NULL;
01030     }
01031     catch(...)  // catch the rest!
01032     {
01033         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
01034         return NULL;
01035     }
01036 #else  // DONT_CATCH_CXX_EXCEPTIONS  
01037     catch(const Base::Exception& e) // catch the FreeCAD exceptions
01038     {
01039         std::string str;
01040         str += "FreeCAD exception thrown (";
01041         str += e.what();
01042         str += ")";
01043         e.ReportException();
01044         PyErr_SetString(PyExc_Exception,str.c_str());
01045         return NULL;
01046     }
01047     catch(const Py::Exception&)
01048     {
01049         // The exception text is already set
01050         return NULL;
01051     }
01052 #endif  // DONT_CATCH_CXX_EXCEPTIONS
01053 
01054     PyObject *rvalue = Py_FindMethod(Methods, this, attr);
01055     if (rvalue == NULL)
01056     {
01057         PyErr_Clear();
01058         return PropertyContainerPy::_getattr(attr);
01059     }
01060     else
01061     {
01062         return rvalue;
01063     }
01064 }
01065 
01066 int ViewProviderPy::_setattr(char *attr, PyObject *value)       // __setattr__ function: note only need to handle new state
01067 {
01068     try {
01069         // setter for  special Attributes (e.g. dynamic ones)
01070         int r = setCustomAttributes(attr, value);
01071         if(r==1) return 0;
01072     }
01073 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
01074     catch(const Base::Exception& e) // catch the FreeCAD exceptions
01075     {
01076         std::string str;
01077         str += "FreeCAD exception thrown (";
01078         str += e.what();
01079         str += ")";
01080         e.ReportException();
01081         PyErr_SetString(PyExc_Exception,str.c_str());
01082         return -1;
01083     }
01084     catch(const std::exception& e) // catch other c++ exceptions
01085     {
01086         std::string str;
01087         str += "FC++ exception thrown (";
01088         str += e.what();
01089         str += ")";
01090         Base::Console().Error(str.c_str());
01091         PyErr_SetString(PyExc_Exception,str.c_str());
01092         return -1;
01093     }
01094     catch(const Py::Exception&)
01095     {
01096         // The exception text is already set
01097         return -1;
01098     }
01099     catch(...)  // catch the rest!
01100     {
01101         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
01102         return -1;
01103     }
01104 #else  // DONT_CATCH_CXX_EXCEPTIONS  
01105     catch(const Base::Exception& e) // catch the FreeCAD exceptions
01106     {
01107         std::string str;
01108         str += "FreeCAD exception thrown (";
01109         str += e.what();
01110         str += ")";
01111         e.ReportException();
01112         PyErr_SetString(PyExc_Exception,str.c_str());
01113         return -1;
01114     }
01115     catch(const Py::Exception&)
01116     {
01117         // The exception text is already set
01118         return -1;
01119     }
01120 #endif  // DONT_CATCH_CXX_EXCEPTIONS
01121 
01122     return PropertyContainerPy::_setattr(attr, value);
01123 }
01124 
01125 ViewProvider *ViewProviderPy::getViewProviderPtr(void) const
01126 {
01127     return static_cast<ViewProvider *>(_pcTwinPointer);
01128 }
01129 
01130 #if 0
01131 /* From here on come the methods you have to implement, but NOT in this module. Implement in ViewProviderPyImp.cpp! This prototypes 
01132  * are just for convenience when you add a new method.
01133  */
01134 
01135 
01136 // returns a string which represents the object e.g. when printed in python
01137 std::string ViewProviderPy::representation(void) const
01138 {
01139     return std::string("<ViewProvider object>");
01140 }
01141 
01142 PyObject* ViewProviderPy::show(PyObject *args)
01143 {
01144     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01145     return 0;
01146 }
01147 
01148 PyObject* ViewProviderPy::hide(PyObject *args)
01149 {
01150     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01151     return 0;
01152 }
01153 
01154 PyObject* ViewProviderPy::isVisible(PyObject *args)
01155 {
01156     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01157     return 0;
01158 }
01159 
01160 PyObject* ViewProviderPy::listDisplayModes(PyObject *args)
01161 {
01162     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01163     return 0;
01164 }
01165 
01166 PyObject* ViewProviderPy::toString(PyObject *args)
01167 {
01168     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01169     return 0;
01170 }
01171 
01172 PyObject* ViewProviderPy::startEditing(PyObject *args)
01173 {
01174     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01175     return 0;
01176 }
01177 
01178 PyObject* ViewProviderPy::finishEditing(PyObject *args)
01179 {
01180     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01181     return 0;
01182 }
01183 
01184 PyObject* ViewProviderPy::isEditing(PyObject *args)
01185 {
01186     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01187     return 0;
01188 }
01189 
01190 PyObject* ViewProviderPy::setTransformation(PyObject *args)
01191 {
01192     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
01193     return 0;
01194 }
01195 
01196 
01197 
01198 Py::Object ViewProviderPy::getAnnotation(void) const
01199 {
01200     //return Py::Object();
01201     throw Py::AttributeError("Not yet implemented");
01202 }
01203 
01204 void  ViewProviderPy::setAnnotation(Py::Object arg)
01205 {
01206     throw Py::AttributeError("Not yet implemented");
01207 }
01208 
01209 Py::Object ViewProviderPy::getRootNode(void) const
01210 {
01211     //return Py::Object();
01212     throw Py::AttributeError("Not yet implemented");
01213 }
01214 
01215 void  ViewProviderPy::setRootNode(Py::Object arg)
01216 {
01217     throw Py::AttributeError("Not yet implemented");
01218 }
01219 
01220 Py::String ViewProviderPy::getIV(void) const
01221 {
01222     //return Py::String();
01223     throw Py::AttributeError("Not yet implemented");
01224 }
01225 
01226 PyObject *ViewProviderPy::getCustomAttributes(const char* attr) const
01227 {
01228     return 0;
01229 }
01230 
01231 int ViewProviderPy::setCustomAttributes(const char* attr, PyObject *obj)
01232 {
01233     return 0; 
01234 }
01235 #endif
01236 
01237 
01238 

Generated on Wed Nov 23 19:01:00 2011 for FreeCAD by  doxygen 1.6.1