RotationPy.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 RotationPyImp.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 Base;
00018 
00020 PyTypeObject RotationPy::Type = {
00021     PyObject_HEAD_INIT(&PyType_Type)
00022     0,                                                /*ob_size*/
00023     "Base.Rotation",     /*tp_name*/
00024     sizeof(RotationPy),                       /*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     "A Rotation",           /*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     Base::RotationPy::Methods,                     /*tp_methods */
00053     0,                                                /*tp_members */
00054     Base::RotationPy::GetterSetter,                     /*tp_getset */
00055     &Base::PyObjectBase::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     Base::RotationPy::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 RotationPy::Methods[] = {
00075     {"invert",
00076         (PyCFunction) staticCallback_invert,
00077         METH_VARARGS,
00078         "\n                                     move(Vector)\n                                  Move the matrix along the vector\n                              "
00079     },
00080     {"multiply",
00081         (PyCFunction) staticCallback_multiply,
00082         METH_VARARGS,
00083         "\n                                     multiply(Rotation)\n                                    Multiply this quaternion with another quaternion\n                              "
00084     },
00085     {"multVec",
00086         (PyCFunction) staticCallback_multVec,
00087         METH_VARARGS,
00088         "\n                                     multVec(Vector) -> Vector\n                                     Compute the transformed vector using the rotation\n                             "
00089     },
00090     {"toEuler",
00091         (PyCFunction) staticCallback_toEuler,
00092         METH_VARARGS,
00093         "\n                                     toEuler(Vector) -> list\n                                       Get the Euler angles of this rotation\n                         "
00094     },
00095     {NULL, NULL, 0, NULL}               /* Sentinel */
00096 };
00097 
00098 
00099 
00101 PyGetSetDef RotationPy::GetterSetter[] = {
00102     {"Q",
00103         (getter) staticCallback_getQ,
00104         (setter) staticCallback_setQ, 
00105         "The rotation elements (as quaternion)",
00106         NULL
00107     },
00108     {"Axis",
00109         (getter) staticCallback_getAxis,
00110         (setter) staticCallback_setAxis, 
00111         "The rotation axis of the quaternion",
00112         NULL
00113     },
00114     {"Angle",
00115         (getter) staticCallback_getAngle,
00116         (setter) staticCallback_setAngle, 
00117         "The rotation angle of the quaternion",
00118         NULL
00119     },
00120     {NULL, NULL, NULL, NULL, NULL}              /* Sentinel */
00121 };
00122 
00123 // invert() callback and implementer
00124 // PyObject*  RotationPy::invert(PyObject *args){};
00125 // has to be implemented in RotationPyImp.cpp
00126 PyObject * RotationPy::staticCallback_invert (PyObject *self, PyObject *args)
00127 {
00128     // test if twin object not allready deleted
00129     if (!((PyObjectBase*) self)->isValid()){
00130         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00131         return NULL;
00132     }
00133 
00134     // test if object is set Const
00135     if (((PyObjectBase*) self)->isConst()){
00136         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00137         return NULL;
00138     }
00139 
00140     try { // catches all exceptions coming up from c++ and generate a python exception
00141         PyObject* ret = ((RotationPy*)self)->invert(args);
00142         if (ret != 0)
00143             ((RotationPy*)self)->startNotify();
00144         return ret;
00145     }
00146     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00147     {
00148         std::string str;
00149         str += "FreeCAD exception thrown (";
00150         str += e.what();
00151         str += ")";
00152         e.ReportException();
00153         PyErr_SetString(PyExc_Exception,str.c_str());
00154         return NULL;
00155     }
00156     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00157     {
00158         std::string str;
00159         str += "File system exception thrown (";
00160         //str += e.who();
00161         //str += ", ";
00162         str += e.what();
00163         str += ")\n";
00164         Base::Console().Error(str.c_str());
00165         PyErr_SetString(PyExc_Exception,str.c_str());
00166         return NULL;
00167     }
00168     catch(const Py::Exception&)
00169     {
00170         // The exception text is already set
00171         return NULL;
00172     }
00173     catch(const char* e) // catch simple string exceptions
00174     {
00175         Base::Console().Error(e);
00176         PyErr_SetString(PyExc_Exception,e);
00177         return NULL;
00178     }
00179     // in debug not all exceptions will be catched to get the attention of the developer!
00180 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00181     catch(const std::exception& e) // catch other c++ exceptions
00182     {
00183         std::string str;
00184         str += "FC++ exception thrown (";
00185         str += e.what();
00186         str += ")";
00187         Base::Console().Error(str.c_str());
00188         PyErr_SetString(PyExc_Exception,str.c_str());
00189         return NULL;
00190     }
00191     catch(...)  // catch the rest!
00192     {
00193         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00194         return NULL;
00195     }
00196 #endif
00197 }
00198 
00199 // multiply() callback and implementer
00200 // PyObject*  RotationPy::multiply(PyObject *args){};
00201 // has to be implemented in RotationPyImp.cpp
00202 PyObject * RotationPy::staticCallback_multiply (PyObject *self, PyObject *args)
00203 {
00204     // test if twin object not allready deleted
00205     if (!((PyObjectBase*) self)->isValid()){
00206         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00207         return NULL;
00208     }
00209 
00210     // test if object is set Const
00211     if (((PyObjectBase*) self)->isConst()){
00212         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00213         return NULL;
00214     }
00215 
00216     try { // catches all exceptions coming up from c++ and generate a python exception
00217         PyObject* ret = ((RotationPy*)self)->multiply(args);
00218         if (ret != 0)
00219             ((RotationPy*)self)->startNotify();
00220         return ret;
00221     }
00222     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00223     {
00224         std::string str;
00225         str += "FreeCAD exception thrown (";
00226         str += e.what();
00227         str += ")";
00228         e.ReportException();
00229         PyErr_SetString(PyExc_Exception,str.c_str());
00230         return NULL;
00231     }
00232     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00233     {
00234         std::string str;
00235         str += "File system exception thrown (";
00236         //str += e.who();
00237         //str += ", ";
00238         str += e.what();
00239         str += ")\n";
00240         Base::Console().Error(str.c_str());
00241         PyErr_SetString(PyExc_Exception,str.c_str());
00242         return NULL;
00243     }
00244     catch(const Py::Exception&)
00245     {
00246         // The exception text is already set
00247         return NULL;
00248     }
00249     catch(const char* e) // catch simple string exceptions
00250     {
00251         Base::Console().Error(e);
00252         PyErr_SetString(PyExc_Exception,e);
00253         return NULL;
00254     }
00255     // in debug not all exceptions will be catched to get the attention of the developer!
00256 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00257     catch(const std::exception& e) // catch other c++ exceptions
00258     {
00259         std::string str;
00260         str += "FC++ exception thrown (";
00261         str += e.what();
00262         str += ")";
00263         Base::Console().Error(str.c_str());
00264         PyErr_SetString(PyExc_Exception,str.c_str());
00265         return NULL;
00266     }
00267     catch(...)  // catch the rest!
00268     {
00269         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00270         return NULL;
00271     }
00272 #endif
00273 }
00274 
00275 // multVec() callback and implementer
00276 // PyObject*  RotationPy::multVec(PyObject *args){};
00277 // has to be implemented in RotationPyImp.cpp
00278 PyObject * RotationPy::staticCallback_multVec (PyObject *self, PyObject *args)
00279 {
00280     // test if twin object not allready deleted
00281     if (!((PyObjectBase*) self)->isValid()){
00282         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00283         return NULL;
00284     }
00285 
00286     // test if object is set Const
00287     if (((PyObjectBase*) self)->isConst()){
00288         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00289         return NULL;
00290     }
00291 
00292     try { // catches all exceptions coming up from c++ and generate a python exception
00293         PyObject* ret = ((RotationPy*)self)->multVec(args);
00294         if (ret != 0)
00295             ((RotationPy*)self)->startNotify();
00296         return ret;
00297     }
00298     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00299     {
00300         std::string str;
00301         str += "FreeCAD exception thrown (";
00302         str += e.what();
00303         str += ")";
00304         e.ReportException();
00305         PyErr_SetString(PyExc_Exception,str.c_str());
00306         return NULL;
00307     }
00308     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00309     {
00310         std::string str;
00311         str += "File system exception thrown (";
00312         //str += e.who();
00313         //str += ", ";
00314         str += e.what();
00315         str += ")\n";
00316         Base::Console().Error(str.c_str());
00317         PyErr_SetString(PyExc_Exception,str.c_str());
00318         return NULL;
00319     }
00320     catch(const Py::Exception&)
00321     {
00322         // The exception text is already set
00323         return NULL;
00324     }
00325     catch(const char* e) // catch simple string exceptions
00326     {
00327         Base::Console().Error(e);
00328         PyErr_SetString(PyExc_Exception,e);
00329         return NULL;
00330     }
00331     // in debug not all exceptions will be catched to get the attention of the developer!
00332 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00333     catch(const std::exception& e) // catch other c++ exceptions
00334     {
00335         std::string str;
00336         str += "FC++ exception thrown (";
00337         str += e.what();
00338         str += ")";
00339         Base::Console().Error(str.c_str());
00340         PyErr_SetString(PyExc_Exception,str.c_str());
00341         return NULL;
00342     }
00343     catch(...)  // catch the rest!
00344     {
00345         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00346         return NULL;
00347     }
00348 #endif
00349 }
00350 
00351 // toEuler() callback and implementer
00352 // PyObject*  RotationPy::toEuler(PyObject *args){};
00353 // has to be implemented in RotationPyImp.cpp
00354 PyObject * RotationPy::staticCallback_toEuler (PyObject *self, PyObject *args)
00355 {
00356     // test if twin object not allready deleted
00357     if (!((PyObjectBase*) self)->isValid()){
00358         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00359         return NULL;
00360     }
00361 
00362     // test if object is set Const
00363     if (((PyObjectBase*) self)->isConst()){
00364         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00365         return NULL;
00366     }
00367 
00368     try { // catches all exceptions coming up from c++ and generate a python exception
00369         PyObject* ret = ((RotationPy*)self)->toEuler(args);
00370         if (ret != 0)
00371             ((RotationPy*)self)->startNotify();
00372         return ret;
00373     }
00374     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00375     {
00376         std::string str;
00377         str += "FreeCAD exception thrown (";
00378         str += e.what();
00379         str += ")";
00380         e.ReportException();
00381         PyErr_SetString(PyExc_Exception,str.c_str());
00382         return NULL;
00383     }
00384     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00385     {
00386         std::string str;
00387         str += "File system exception thrown (";
00388         //str += e.who();
00389         //str += ", ";
00390         str += e.what();
00391         str += ")\n";
00392         Base::Console().Error(str.c_str());
00393         PyErr_SetString(PyExc_Exception,str.c_str());
00394         return NULL;
00395     }
00396     catch(const Py::Exception&)
00397     {
00398         // The exception text is already set
00399         return NULL;
00400     }
00401     catch(const char* e) // catch simple string exceptions
00402     {
00403         Base::Console().Error(e);
00404         PyErr_SetString(PyExc_Exception,e);
00405         return NULL;
00406     }
00407     // in debug not all exceptions will be catched to get the attention of the developer!
00408 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00409     catch(const std::exception& e) // catch other c++ exceptions
00410     {
00411         std::string str;
00412         str += "FC++ exception thrown (";
00413         str += e.what();
00414         str += ")";
00415         Base::Console().Error(str.c_str());
00416         PyErr_SetString(PyExc_Exception,str.c_str());
00417         return NULL;
00418     }
00419     catch(...)  // catch the rest!
00420     {
00421         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00422         return NULL;
00423     }
00424 #endif
00425 }
00426 
00427 // Q() callback and implementer
00428 // PyObject*  RotationPy::Q(PyObject *args){};
00429 // has to be implemented in RotationPyImp.cpp
00430 PyObject * RotationPy::staticCallback_getQ (PyObject *self, void * /*closure*/)
00431 {
00432     if (!((PyObjectBase*) self)->isValid()){
00433         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00434         return NULL;
00435     }
00436 
00437     try {
00438         return Py::new_reference_to(((RotationPy*)self)->getQ());
00439     } catch (const Py::Exception&) {
00440         // The exception text is already set
00441         return NULL;
00442     } catch (...) {
00443         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Q' of object 'Rotation'");
00444         return NULL;
00445     }
00446 }
00447 
00448 int RotationPy::staticCallback_setQ (PyObject *self, PyObject *value, void * /*closure*/)
00449 {    
00450     if (!((PyObjectBase*) self)->isValid()){
00451         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00452         return -1;
00453     }
00454     if (((PyObjectBase*) self)->isConst()){
00455         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
00456         return -1;
00457     }
00458 
00459     try {
00460         ((RotationPy*)self)->setQ(Py::Tuple(value,false));
00461         return 0;
00462     } catch (const Py::Exception&) {
00463         // The exception text is already set
00464         return -1;
00465     } catch (...) {
00466         PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'Q' of object 'Rotation'");
00467         return -1;
00468     }
00469 }
00470 
00471 // Axis() callback and implementer
00472 // PyObject*  RotationPy::Axis(PyObject *args){};
00473 // has to be implemented in RotationPyImp.cpp
00474 PyObject * RotationPy::staticCallback_getAxis (PyObject *self, void * /*closure*/)
00475 {
00476     if (!((PyObjectBase*) self)->isValid()){
00477         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00478         return NULL;
00479     }
00480 
00481     try {
00482         return Py::new_reference_to(((RotationPy*)self)->getAxis());
00483     } catch (const Py::Exception&) {
00484         // The exception text is already set
00485         return NULL;
00486     } catch (...) {
00487         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Axis' of object 'Rotation'");
00488         return NULL;
00489     }
00490 }
00491 
00492 int RotationPy::staticCallback_setAxis (PyObject *self, PyObject * /*value*/, void * /*closure*/)
00493 {
00494     if (!((PyObjectBase*) self)->isValid()){
00495         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00496         return -1;
00497     }
00498 
00499     PyErr_SetString(PyExc_AttributeError, "Attribute 'Axis' of object 'Rotation' is read-only");
00500     return -1;
00501 }
00502 
00503 // Angle() callback and implementer
00504 // PyObject*  RotationPy::Angle(PyObject *args){};
00505 // has to be implemented in RotationPyImp.cpp
00506 PyObject * RotationPy::staticCallback_getAngle (PyObject *self, void * /*closure*/)
00507 {
00508     if (!((PyObjectBase*) self)->isValid()){
00509         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00510         return NULL;
00511     }
00512 
00513     try {
00514         return Py::new_reference_to(((RotationPy*)self)->getAngle());
00515     } catch (const Py::Exception&) {
00516         // The exception text is already set
00517         return NULL;
00518     } catch (...) {
00519         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Angle' of object 'Rotation'");
00520         return NULL;
00521     }
00522 }
00523 
00524 int RotationPy::staticCallback_setAngle (PyObject *self, PyObject * /*value*/, void * /*closure*/)
00525 {
00526     if (!((PyObjectBase*) self)->isValid()){
00527         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00528         return -1;
00529     }
00530 
00531     PyErr_SetString(PyExc_AttributeError, "Attribute 'Angle' of object 'Rotation' is read-only");
00532     return -1;
00533 }
00534 
00535 
00536 
00537 //--------------------------------------------------------------------------
00538 // Parents structure
00539 //--------------------------------------------------------------------------
00540 PyParentObject RotationPy::Parents[] = { PARENTSBaseRotationPy };
00541 
00542 //--------------------------------------------------------------------------
00543 // Constructor
00544 //--------------------------------------------------------------------------
00545 RotationPy::RotationPy(Rotation *pcObject, PyTypeObject *T)
00546     : PyObjectBase(reinterpret_cast<PyObjectBase::PointerType>(pcObject), T)
00547 {
00548 }
00549 
00550 
00551 //--------------------------------------------------------------------------
00552 // destructor
00553 //--------------------------------------------------------------------------
00554 RotationPy::~RotationPy()                                // Everything handled in parent
00555 {
00556     // delete the handled object when the PyObject dies
00557     RotationPy::PointerType ptr = reinterpret_cast<RotationPy::PointerType>(_pcTwinPointer);
00558     delete ptr;
00559 }
00560 
00561 //--------------------------------------------------------------------------
00562 // RotationPy representation
00563 //--------------------------------------------------------------------------
00564 PyObject *RotationPy::_repr(void)
00565 {
00566     return Py_BuildValue("s", representation().c_str());
00567 }
00568 
00569 //--------------------------------------------------------------------------
00570 // RotationPy Attributes
00571 //--------------------------------------------------------------------------
00572 PyObject *RotationPy::_getattr(char *attr)                              // __getattr__ function: note only need to handle new state
00573 {
00574     try {
00575         // getter method for special Attributes (e.g. dynamic ones)
00576         PyObject *r = getCustomAttributes(attr);
00577         if(r) return r;
00578     }
00579 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00580     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00581     {
00582         std::string str;
00583         str += "FreeCAD exception thrown (";
00584         str += e.what();
00585         str += ")";
00586         e.ReportException();
00587         PyErr_SetString(PyExc_Exception,str.c_str());
00588         return NULL;
00589     }
00590     catch(const std::exception& e) // catch other c++ exceptions
00591     {
00592         std::string str;
00593         str += "FC++ exception thrown (";
00594         str += e.what();
00595         str += ")";
00596         Base::Console().Error(str.c_str());
00597         PyErr_SetString(PyExc_Exception,str.c_str());
00598         return NULL;
00599     }
00600     catch(const Py::Exception&)
00601     {
00602         // The exception text is already set
00603         return NULL;
00604     }
00605     catch(...)  // catch the rest!
00606     {
00607         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00608         return NULL;
00609     }
00610 #else  // DONT_CATCH_CXX_EXCEPTIONS  
00611     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00612     {
00613         std::string str;
00614         str += "FreeCAD exception thrown (";
00615         str += e.what();
00616         str += ")";
00617         e.ReportException();
00618         PyErr_SetString(PyExc_Exception,str.c_str());
00619         return NULL;
00620     }
00621     catch(const Py::Exception&)
00622     {
00623         // The exception text is already set
00624         return NULL;
00625     }
00626 #endif  // DONT_CATCH_CXX_EXCEPTIONS
00627 
00628     PyObject *rvalue = Py_FindMethod(Methods, this, attr);
00629     if (rvalue == NULL)
00630     {
00631         PyErr_Clear();
00632         return PyObjectBase::_getattr(attr);
00633     }
00634     else
00635     {
00636         return rvalue;
00637     }
00638 }
00639 
00640 int RotationPy::_setattr(char *attr, PyObject *value)   // __setattr__ function: note only need to handle new state
00641 {
00642     try {
00643         // setter for  special Attributes (e.g. dynamic ones)
00644         int r = setCustomAttributes(attr, value);
00645         if(r==1) return 0;
00646     }
00647 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00648     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00649     {
00650         std::string str;
00651         str += "FreeCAD exception thrown (";
00652         str += e.what();
00653         str += ")";
00654         e.ReportException();
00655         PyErr_SetString(PyExc_Exception,str.c_str());
00656         return -1;
00657     }
00658     catch(const std::exception& e) // catch other c++ exceptions
00659     {
00660         std::string str;
00661         str += "FC++ exception thrown (";
00662         str += e.what();
00663         str += ")";
00664         Base::Console().Error(str.c_str());
00665         PyErr_SetString(PyExc_Exception,str.c_str());
00666         return -1;
00667     }
00668     catch(const Py::Exception&)
00669     {
00670         // The exception text is already set
00671         return -1;
00672     }
00673     catch(...)  // catch the rest!
00674     {
00675         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00676         return -1;
00677     }
00678 #else  // DONT_CATCH_CXX_EXCEPTIONS  
00679     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00680     {
00681         std::string str;
00682         str += "FreeCAD exception thrown (";
00683         str += e.what();
00684         str += ")";
00685         e.ReportException();
00686         PyErr_SetString(PyExc_Exception,str.c_str());
00687         return -1;
00688     }
00689     catch(const Py::Exception&)
00690     {
00691         // The exception text is already set
00692         return -1;
00693     }
00694 #endif  // DONT_CATCH_CXX_EXCEPTIONS
00695 
00696     return PyObjectBase::_setattr(attr, value);
00697 }
00698 
00699 Rotation *RotationPy::getRotationPtr(void) const
00700 {
00701     return static_cast<Rotation *>(_pcTwinPointer);
00702 }
00703 
00704 #if 0
00705 /* From here on come the methods you have to implement, but NOT in this module. Implement in RotationPyImp.cpp! This prototypes 
00706  * are just for convenience when you add a new method.
00707  */
00708 
00709 PyObject *RotationPy::PyMake(struct _typeobject *, PyObject *, PyObject *)  // Python wrapper
00710 {
00711     // create a new instance of RotationPy and the Twin object 
00712     return new RotationPy(new Rotation);
00713 }
00714 
00715 // constructor method
00716 int RotationPy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
00717 {
00718     return 0;
00719 }
00720 
00721 // returns a string which represents the object e.g. when printed in python
00722 std::string RotationPy::representation(void) const
00723 {
00724     return std::string("<Rotation object>");
00725 }
00726 
00727 PyObject* RotationPy::invert(PyObject *args)
00728 {
00729     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
00730     return 0;
00731 }
00732 
00733 PyObject* RotationPy::multiply(PyObject *args)
00734 {
00735     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
00736     return 0;
00737 }
00738 
00739 PyObject* RotationPy::multVec(PyObject *args)
00740 {
00741     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
00742     return 0;
00743 }
00744 
00745 PyObject* RotationPy::toEuler(PyObject *args)
00746 {
00747     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
00748     return 0;
00749 }
00750 
00751 
00752 
00753 Py::Tuple RotationPy::getQ(void) const
00754 {
00755     //return Py::Tuple();
00756     throw Py::AttributeError("Not yet implemented");
00757 }
00758 
00759 void  RotationPy::setQ(Py::Tuple arg)
00760 {
00761     throw Py::AttributeError("Not yet implemented");
00762 }
00763 
00764 Py::Object RotationPy::getAxis(void) const
00765 {
00766     //return Py::Object();
00767     throw Py::AttributeError("Not yet implemented");
00768 }
00769 
00770 Py::Float RotationPy::getAngle(void) const
00771 {
00772     //return Py::Float();
00773     throw Py::AttributeError("Not yet implemented");
00774 }
00775 
00776 PyObject *RotationPy::getCustomAttributes(const char* attr) const
00777 {
00778     return 0;
00779 }
00780 
00781 int RotationPy::setCustomAttributes(const char* attr, PyObject *obj)
00782 {
00783     return 0; 
00784 }
00785 #endif
00786 
00787 
00788 

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