PlacementPy.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 PlacementPyImp.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 PlacementPy::Type = {
00021     PyObject_HEAD_INIT(&PyType_Type)
00022     0,                                                /*ob_size*/
00023     "Base.Placement",     /*tp_name*/
00024     sizeof(PlacementPy),                       /*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     "Placement\n"
00046     "A placement defines an orientation (rotation) and a position (base) in 3D space.\n"
00047     "It is used when no scaling or other distortion is needed.\n"
00048     "\n"
00049     "The following constructors are supported:\n"
00050     "Placement() -- empty constructor\n"
00051     "Placement(Placement) -- copy constructor\n"
00052     "Placement(Matrix) -- 4D matrix consisting of rotation and translation\n"
00053     "Placement(Base, Rotation) -- define position and rotation\n"
00054     "Placement(Base, Rotation,Center) -- define position and rotation with center\n"
00055     "Placement(Base, Axis, Angle) -- define position and rotation\n"
00056     "           ",           /*tp_doc */
00057     0,                                                /*tp_traverse */
00058     0,                                                /*tp_clear */
00059     0,                                                /*tp_richcompare */
00060     0,                                                /*tp_weaklistoffset */
00061     0,                                                /*tp_iter */
00062     0,                                                /*tp_iternext */
00063     Base::PlacementPy::Methods,                     /*tp_methods */
00064     0,                                                /*tp_members */
00065     Base::PlacementPy::GetterSetter,                     /*tp_getset */
00066     &Base::PyObjectBase::Type,                        /*tp_base */
00067     0,                                                /*tp_dict */
00068     0,                                                /*tp_descr_get */
00069     0,                                                /*tp_descr_set */
00070     0,                                                /*tp_dictoffset */
00071     __PyInit,                                         /*tp_init */
00072     0,                                                /*tp_alloc */
00073     Base::PlacementPy::PyMake,/*tp_new */
00074     0,                                                /*tp_free   Low-level free-memory routine */
00075     0,                                                /*tp_is_gc  For PyObject_IS_GC */
00076     0,                                                /*tp_bases */
00077     0,                                                /*tp_mro    method resolution order */
00078     0,                                                /*tp_cache */
00079     0,                                                /*tp_subclasses */
00080     0,                                                /*tp_weaklist */
00081     0                                                 /*tp_del */
00082 };
00083 
00085 PyMethodDef PlacementPy::Methods[] = {
00086     {"copy",
00087         (PyCFunction) staticCallback_copy,
00088         METH_VARARGS,
00089         "\n                    copy()\n                    Returns a copy of this Placement\n                "
00090     },
00091     {"move",
00092         (PyCFunction) staticCallback_move,
00093         METH_VARARGS,
00094         "\n                                     move(Vector) \n                                 Move the placement along the vector\n                           "
00095     },
00096     {"multiply",
00097         (PyCFunction) staticCallback_multiply,
00098         METH_VARARGS,
00099         "\n                                     multiply(Placement)\n                                   Multiply this placement with another placement\n                                "
00100     },
00101     {"multVec",
00102         (PyCFunction) staticCallback_multVec,
00103         METH_VARARGS,
00104         "\n                                     multVector(Vector) -> Vector\n                                  Compute the transformed vector using the placement\n                            "
00105     },
00106     {"toMatrix",
00107         (PyCFunction) staticCallback_toMatrix,
00108         METH_VARARGS,
00109         "\n                                     toMatrix()\n                                    convert the placement to a matrix representation\n                              "
00110     },
00111     {"inverse",
00112         (PyCFunction) staticCallback_inverse,
00113         METH_VARARGS,
00114         "\n                                     inverse() -> Placement\n                                        compute the inverse placement\n                         "
00115     },
00116     {NULL, NULL, 0, NULL}               /* Sentinel */
00117 };
00118 
00119 
00120 
00122 PyGetSetDef PlacementPy::GetterSetter[] = {
00123     {"Base",
00124         (getter) staticCallback_getBase,
00125         (setter) staticCallback_setBase, 
00126         "Vector to the Base Position of the Placement",
00127         NULL
00128     },
00129     {"Rotation",
00130         (getter) staticCallback_getRotation,
00131         (setter) staticCallback_setRotation, 
00132         "Orientation of the placement expressed as rotation",
00133         NULL
00134     },
00135     {NULL, NULL, NULL, NULL, NULL}              /* Sentinel */
00136 };
00137 
00138 // copy() callback and implementer
00139 // PyObject*  PlacementPy::copy(PyObject *args){};
00140 // has to be implemented in PlacementPyImp.cpp
00141 PyObject * PlacementPy::staticCallback_copy (PyObject *self, PyObject *args)
00142 {
00143     // test if twin object not allready deleted
00144     if (!((PyObjectBase*) self)->isValid()){
00145         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00146         return NULL;
00147     }
00148 
00149     // test if object is set Const
00150     if (((PyObjectBase*) self)->isConst()){
00151         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00152         return NULL;
00153     }
00154 
00155     try { // catches all exceptions coming up from c++ and generate a python exception
00156         PyObject* ret = ((PlacementPy*)self)->copy(args);
00157         if (ret != 0)
00158             ((PlacementPy*)self)->startNotify();
00159         return ret;
00160     }
00161     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00162     {
00163         std::string str;
00164         str += "FreeCAD exception thrown (";
00165         str += e.what();
00166         str += ")";
00167         e.ReportException();
00168         PyErr_SetString(PyExc_Exception,str.c_str());
00169         return NULL;
00170     }
00171     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00172     {
00173         std::string str;
00174         str += "File system exception thrown (";
00175         //str += e.who();
00176         //str += ", ";
00177         str += e.what();
00178         str += ")\n";
00179         Base::Console().Error(str.c_str());
00180         PyErr_SetString(PyExc_Exception,str.c_str());
00181         return NULL;
00182     }
00183     catch(const Py::Exception&)
00184     {
00185         // The exception text is already set
00186         return NULL;
00187     }
00188     catch(const char* e) // catch simple string exceptions
00189     {
00190         Base::Console().Error(e);
00191         PyErr_SetString(PyExc_Exception,e);
00192         return NULL;
00193     }
00194     // in debug not all exceptions will be catched to get the attention of the developer!
00195 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00196     catch(const std::exception& e) // catch other c++ exceptions
00197     {
00198         std::string str;
00199         str += "FC++ exception thrown (";
00200         str += e.what();
00201         str += ")";
00202         Base::Console().Error(str.c_str());
00203         PyErr_SetString(PyExc_Exception,str.c_str());
00204         return NULL;
00205     }
00206     catch(...)  // catch the rest!
00207     {
00208         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00209         return NULL;
00210     }
00211 #endif
00212 }
00213 
00214 // move() callback and implementer
00215 // PyObject*  PlacementPy::move(PyObject *args){};
00216 // has to be implemented in PlacementPyImp.cpp
00217 PyObject * PlacementPy::staticCallback_move (PyObject *self, PyObject *args)
00218 {
00219     // test if twin object not allready deleted
00220     if (!((PyObjectBase*) self)->isValid()){
00221         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00222         return NULL;
00223     }
00224 
00225     // test if object is set Const
00226     if (((PyObjectBase*) self)->isConst()){
00227         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00228         return NULL;
00229     }
00230 
00231     try { // catches all exceptions coming up from c++ and generate a python exception
00232         PyObject* ret = ((PlacementPy*)self)->move(args);
00233         if (ret != 0)
00234             ((PlacementPy*)self)->startNotify();
00235         return ret;
00236     }
00237     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00238     {
00239         std::string str;
00240         str += "FreeCAD exception thrown (";
00241         str += e.what();
00242         str += ")";
00243         e.ReportException();
00244         PyErr_SetString(PyExc_Exception,str.c_str());
00245         return NULL;
00246     }
00247     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00248     {
00249         std::string str;
00250         str += "File system exception thrown (";
00251         //str += e.who();
00252         //str += ", ";
00253         str += e.what();
00254         str += ")\n";
00255         Base::Console().Error(str.c_str());
00256         PyErr_SetString(PyExc_Exception,str.c_str());
00257         return NULL;
00258     }
00259     catch(const Py::Exception&)
00260     {
00261         // The exception text is already set
00262         return NULL;
00263     }
00264     catch(const char* e) // catch simple string exceptions
00265     {
00266         Base::Console().Error(e);
00267         PyErr_SetString(PyExc_Exception,e);
00268         return NULL;
00269     }
00270     // in debug not all exceptions will be catched to get the attention of the developer!
00271 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00272     catch(const std::exception& e) // catch other c++ exceptions
00273     {
00274         std::string str;
00275         str += "FC++ exception thrown (";
00276         str += e.what();
00277         str += ")";
00278         Base::Console().Error(str.c_str());
00279         PyErr_SetString(PyExc_Exception,str.c_str());
00280         return NULL;
00281     }
00282     catch(...)  // catch the rest!
00283     {
00284         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00285         return NULL;
00286     }
00287 #endif
00288 }
00289 
00290 // multiply() callback and implementer
00291 // PyObject*  PlacementPy::multiply(PyObject *args){};
00292 // has to be implemented in PlacementPyImp.cpp
00293 PyObject * PlacementPy::staticCallback_multiply (PyObject *self, PyObject *args)
00294 {
00295     // test if twin object not allready deleted
00296     if (!((PyObjectBase*) self)->isValid()){
00297         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00298         return NULL;
00299     }
00300 
00301     // test if object is set Const
00302     if (((PyObjectBase*) self)->isConst()){
00303         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00304         return NULL;
00305     }
00306 
00307     try { // catches all exceptions coming up from c++ and generate a python exception
00308         PyObject* ret = ((PlacementPy*)self)->multiply(args);
00309         if (ret != 0)
00310             ((PlacementPy*)self)->startNotify();
00311         return ret;
00312     }
00313     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00314     {
00315         std::string str;
00316         str += "FreeCAD exception thrown (";
00317         str += e.what();
00318         str += ")";
00319         e.ReportException();
00320         PyErr_SetString(PyExc_Exception,str.c_str());
00321         return NULL;
00322     }
00323     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00324     {
00325         std::string str;
00326         str += "File system exception thrown (";
00327         //str += e.who();
00328         //str += ", ";
00329         str += e.what();
00330         str += ")\n";
00331         Base::Console().Error(str.c_str());
00332         PyErr_SetString(PyExc_Exception,str.c_str());
00333         return NULL;
00334     }
00335     catch(const Py::Exception&)
00336     {
00337         // The exception text is already set
00338         return NULL;
00339     }
00340     catch(const char* e) // catch simple string exceptions
00341     {
00342         Base::Console().Error(e);
00343         PyErr_SetString(PyExc_Exception,e);
00344         return NULL;
00345     }
00346     // in debug not all exceptions will be catched to get the attention of the developer!
00347 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00348     catch(const std::exception& e) // catch other c++ exceptions
00349     {
00350         std::string str;
00351         str += "FC++ exception thrown (";
00352         str += e.what();
00353         str += ")";
00354         Base::Console().Error(str.c_str());
00355         PyErr_SetString(PyExc_Exception,str.c_str());
00356         return NULL;
00357     }
00358     catch(...)  // catch the rest!
00359     {
00360         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00361         return NULL;
00362     }
00363 #endif
00364 }
00365 
00366 // multVec() callback and implementer
00367 // PyObject*  PlacementPy::multVec(PyObject *args){};
00368 // has to be implemented in PlacementPyImp.cpp
00369 PyObject * PlacementPy::staticCallback_multVec (PyObject *self, PyObject *args)
00370 {
00371     // test if twin object not allready deleted
00372     if (!((PyObjectBase*) self)->isValid()){
00373         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00374         return NULL;
00375     }
00376 
00377     // test if object is set Const
00378     if (((PyObjectBase*) self)->isConst()){
00379         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00380         return NULL;
00381     }
00382 
00383     try { // catches all exceptions coming up from c++ and generate a python exception
00384         PyObject* ret = ((PlacementPy*)self)->multVec(args);
00385         if (ret != 0)
00386             ((PlacementPy*)self)->startNotify();
00387         return ret;
00388     }
00389     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00390     {
00391         std::string str;
00392         str += "FreeCAD exception thrown (";
00393         str += e.what();
00394         str += ")";
00395         e.ReportException();
00396         PyErr_SetString(PyExc_Exception,str.c_str());
00397         return NULL;
00398     }
00399     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00400     {
00401         std::string str;
00402         str += "File system exception thrown (";
00403         //str += e.who();
00404         //str += ", ";
00405         str += e.what();
00406         str += ")\n";
00407         Base::Console().Error(str.c_str());
00408         PyErr_SetString(PyExc_Exception,str.c_str());
00409         return NULL;
00410     }
00411     catch(const Py::Exception&)
00412     {
00413         // The exception text is already set
00414         return NULL;
00415     }
00416     catch(const char* e) // catch simple string exceptions
00417     {
00418         Base::Console().Error(e);
00419         PyErr_SetString(PyExc_Exception,e);
00420         return NULL;
00421     }
00422     // in debug not all exceptions will be catched to get the attention of the developer!
00423 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00424     catch(const std::exception& e) // catch other c++ exceptions
00425     {
00426         std::string str;
00427         str += "FC++ exception thrown (";
00428         str += e.what();
00429         str += ")";
00430         Base::Console().Error(str.c_str());
00431         PyErr_SetString(PyExc_Exception,str.c_str());
00432         return NULL;
00433     }
00434     catch(...)  // catch the rest!
00435     {
00436         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00437         return NULL;
00438     }
00439 #endif
00440 }
00441 
00442 // toMatrix() callback and implementer
00443 // PyObject*  PlacementPy::toMatrix(PyObject *args){};
00444 // has to be implemented in PlacementPyImp.cpp
00445 PyObject * PlacementPy::staticCallback_toMatrix (PyObject *self, PyObject *args)
00446 {
00447     // test if twin object not allready deleted
00448     if (!((PyObjectBase*) self)->isValid()){
00449         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00450         return NULL;
00451     }
00452 
00453     // test if object is set Const
00454     if (((PyObjectBase*) self)->isConst()){
00455         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00456         return NULL;
00457     }
00458 
00459     try { // catches all exceptions coming up from c++ and generate a python exception
00460         PyObject* ret = ((PlacementPy*)self)->toMatrix(args);
00461         if (ret != 0)
00462             ((PlacementPy*)self)->startNotify();
00463         return ret;
00464     }
00465     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00466     {
00467         std::string str;
00468         str += "FreeCAD exception thrown (";
00469         str += e.what();
00470         str += ")";
00471         e.ReportException();
00472         PyErr_SetString(PyExc_Exception,str.c_str());
00473         return NULL;
00474     }
00475     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00476     {
00477         std::string str;
00478         str += "File system exception thrown (";
00479         //str += e.who();
00480         //str += ", ";
00481         str += e.what();
00482         str += ")\n";
00483         Base::Console().Error(str.c_str());
00484         PyErr_SetString(PyExc_Exception,str.c_str());
00485         return NULL;
00486     }
00487     catch(const Py::Exception&)
00488     {
00489         // The exception text is already set
00490         return NULL;
00491     }
00492     catch(const char* e) // catch simple string exceptions
00493     {
00494         Base::Console().Error(e);
00495         PyErr_SetString(PyExc_Exception,e);
00496         return NULL;
00497     }
00498     // in debug not all exceptions will be catched to get the attention of the developer!
00499 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00500     catch(const std::exception& e) // catch other c++ exceptions
00501     {
00502         std::string str;
00503         str += "FC++ exception thrown (";
00504         str += e.what();
00505         str += ")";
00506         Base::Console().Error(str.c_str());
00507         PyErr_SetString(PyExc_Exception,str.c_str());
00508         return NULL;
00509     }
00510     catch(...)  // catch the rest!
00511     {
00512         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00513         return NULL;
00514     }
00515 #endif
00516 }
00517 
00518 // inverse() callback and implementer
00519 // PyObject*  PlacementPy::inverse(PyObject *args){};
00520 // has to be implemented in PlacementPyImp.cpp
00521 PyObject * PlacementPy::staticCallback_inverse (PyObject *self, PyObject *args)
00522 {
00523     // test if twin object not allready deleted
00524     if (!((PyObjectBase*) self)->isValid()){
00525         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00526         return NULL;
00527     }
00528 
00529     // test if object is set Const
00530     if (((PyObjectBase*) self)->isConst()){
00531         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00532         return NULL;
00533     }
00534 
00535     try { // catches all exceptions coming up from c++ and generate a python exception
00536         PyObject* ret = ((PlacementPy*)self)->inverse(args);
00537         if (ret != 0)
00538             ((PlacementPy*)self)->startNotify();
00539         return ret;
00540     }
00541     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00542     {
00543         std::string str;
00544         str += "FreeCAD exception thrown (";
00545         str += e.what();
00546         str += ")";
00547         e.ReportException();
00548         PyErr_SetString(PyExc_Exception,str.c_str());
00549         return NULL;
00550     }
00551     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00552     {
00553         std::string str;
00554         str += "File system exception thrown (";
00555         //str += e.who();
00556         //str += ", ";
00557         str += e.what();
00558         str += ")\n";
00559         Base::Console().Error(str.c_str());
00560         PyErr_SetString(PyExc_Exception,str.c_str());
00561         return NULL;
00562     }
00563     catch(const Py::Exception&)
00564     {
00565         // The exception text is already set
00566         return NULL;
00567     }
00568     catch(const char* e) // catch simple string exceptions
00569     {
00570         Base::Console().Error(e);
00571         PyErr_SetString(PyExc_Exception,e);
00572         return NULL;
00573     }
00574     // in debug not all exceptions will be catched to get the attention of the developer!
00575 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00576     catch(const std::exception& e) // catch other c++ exceptions
00577     {
00578         std::string str;
00579         str += "FC++ exception thrown (";
00580         str += e.what();
00581         str += ")";
00582         Base::Console().Error(str.c_str());
00583         PyErr_SetString(PyExc_Exception,str.c_str());
00584         return NULL;
00585     }
00586     catch(...)  // catch the rest!
00587     {
00588         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00589         return NULL;
00590     }
00591 #endif
00592 }
00593 
00594 // Base() callback and implementer
00595 // PyObject*  PlacementPy::Base(PyObject *args){};
00596 // has to be implemented in PlacementPyImp.cpp
00597 PyObject * PlacementPy::staticCallback_getBase (PyObject *self, void * /*closure*/)
00598 {
00599     if (!((PyObjectBase*) self)->isValid()){
00600         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00601         return NULL;
00602     }
00603 
00604     try {
00605         return Py::new_reference_to(((PlacementPy*)self)->getBase());
00606     } catch (const Py::Exception&) {
00607         // The exception text is already set
00608         return NULL;
00609     } catch (...) {
00610         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Base' of object 'Placement'");
00611         return NULL;
00612     }
00613 }
00614 
00615 int PlacementPy::staticCallback_setBase (PyObject *self, PyObject *value, void * /*closure*/)
00616 {    
00617     if (!((PyObjectBase*) self)->isValid()){
00618         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00619         return -1;
00620     }
00621     if (((PyObjectBase*) self)->isConst()){
00622         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
00623         return -1;
00624     }
00625 
00626     try {
00627         ((PlacementPy*)self)->setBase(Py::Object(value,false));
00628         return 0;
00629     } catch (const Py::Exception&) {
00630         // The exception text is already set
00631         return -1;
00632     } catch (...) {
00633         PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'Base' of object 'Placement'");
00634         return -1;
00635     }
00636 }
00637 
00638 // Rotation() callback and implementer
00639 // PyObject*  PlacementPy::Rotation(PyObject *args){};
00640 // has to be implemented in PlacementPyImp.cpp
00641 PyObject * PlacementPy::staticCallback_getRotation (PyObject *self, void * /*closure*/)
00642 {
00643     if (!((PyObjectBase*) self)->isValid()){
00644         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00645         return NULL;
00646     }
00647 
00648     try {
00649         return Py::new_reference_to(((PlacementPy*)self)->getRotation());
00650     } catch (const Py::Exception&) {
00651         // The exception text is already set
00652         return NULL;
00653     } catch (...) {
00654         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Rotation' of object 'Placement'");
00655         return NULL;
00656     }
00657 }
00658 
00659 int PlacementPy::staticCallback_setRotation (PyObject *self, PyObject *value, void * /*closure*/)
00660 {    
00661     if (!((PyObjectBase*) self)->isValid()){
00662         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00663         return -1;
00664     }
00665     if (((PyObjectBase*) self)->isConst()){
00666         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
00667         return -1;
00668     }
00669 
00670     try {
00671         ((PlacementPy*)self)->setRotation(Py::Object(value,false));
00672         return 0;
00673     } catch (const Py::Exception&) {
00674         // The exception text is already set
00675         return -1;
00676     } catch (...) {
00677         PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'Rotation' of object 'Placement'");
00678         return -1;
00679     }
00680 }
00681 
00682 
00683 
00684 //--------------------------------------------------------------------------
00685 // Parents structure
00686 //--------------------------------------------------------------------------
00687 PyParentObject PlacementPy::Parents[] = { PARENTSBasePlacementPy };
00688 
00689 //--------------------------------------------------------------------------
00690 // Constructor
00691 //--------------------------------------------------------------------------
00692 PlacementPy::PlacementPy(Placement *pcObject, PyTypeObject *T)
00693     : PyObjectBase(reinterpret_cast<PyObjectBase::PointerType>(pcObject), T)
00694 {
00695 }
00696 
00697 
00698 //--------------------------------------------------------------------------
00699 // destructor
00700 //--------------------------------------------------------------------------
00701 PlacementPy::~PlacementPy()                                // Everything handled in parent
00702 {
00703     // delete the handled object when the PyObject dies
00704     PlacementPy::PointerType ptr = reinterpret_cast<PlacementPy::PointerType>(_pcTwinPointer);
00705     delete ptr;
00706 }
00707 
00708 //--------------------------------------------------------------------------
00709 // PlacementPy representation
00710 //--------------------------------------------------------------------------
00711 PyObject *PlacementPy::_repr(void)
00712 {
00713     return Py_BuildValue("s", representation().c_str());
00714 }
00715 
00716 //--------------------------------------------------------------------------
00717 // PlacementPy Attributes
00718 //--------------------------------------------------------------------------
00719 PyObject *PlacementPy::_getattr(char *attr)                             // __getattr__ function: note only need to handle new state
00720 {
00721     try {
00722         // getter method for special Attributes (e.g. dynamic ones)
00723         PyObject *r = getCustomAttributes(attr);
00724         if(r) return r;
00725     }
00726 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00727     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00728     {
00729         std::string str;
00730         str += "FreeCAD exception thrown (";
00731         str += e.what();
00732         str += ")";
00733         e.ReportException();
00734         PyErr_SetString(PyExc_Exception,str.c_str());
00735         return NULL;
00736     }
00737     catch(const std::exception& e) // catch other c++ exceptions
00738     {
00739         std::string str;
00740         str += "FC++ exception thrown (";
00741         str += e.what();
00742         str += ")";
00743         Base::Console().Error(str.c_str());
00744         PyErr_SetString(PyExc_Exception,str.c_str());
00745         return NULL;
00746     }
00747     catch(const Py::Exception&)
00748     {
00749         // The exception text is already set
00750         return NULL;
00751     }
00752     catch(...)  // catch the rest!
00753     {
00754         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00755         return NULL;
00756     }
00757 #else  // DONT_CATCH_CXX_EXCEPTIONS  
00758     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00759     {
00760         std::string str;
00761         str += "FreeCAD exception thrown (";
00762         str += e.what();
00763         str += ")";
00764         e.ReportException();
00765         PyErr_SetString(PyExc_Exception,str.c_str());
00766         return NULL;
00767     }
00768     catch(const Py::Exception&)
00769     {
00770         // The exception text is already set
00771         return NULL;
00772     }
00773 #endif  // DONT_CATCH_CXX_EXCEPTIONS
00774 
00775     PyObject *rvalue = Py_FindMethod(Methods, this, attr);
00776     if (rvalue == NULL)
00777     {
00778         PyErr_Clear();
00779         return PyObjectBase::_getattr(attr);
00780     }
00781     else
00782     {
00783         return rvalue;
00784     }
00785 }
00786 
00787 int PlacementPy::_setattr(char *attr, PyObject *value)  // __setattr__ function: note only need to handle new state
00788 {
00789     try {
00790         // setter for  special Attributes (e.g. dynamic ones)
00791         int r = setCustomAttributes(attr, value);
00792         if(r==1) return 0;
00793     }
00794 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00795     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00796     {
00797         std::string str;
00798         str += "FreeCAD exception thrown (";
00799         str += e.what();
00800         str += ")";
00801         e.ReportException();
00802         PyErr_SetString(PyExc_Exception,str.c_str());
00803         return -1;
00804     }
00805     catch(const std::exception& e) // catch other c++ exceptions
00806     {
00807         std::string str;
00808         str += "FC++ exception thrown (";
00809         str += e.what();
00810         str += ")";
00811         Base::Console().Error(str.c_str());
00812         PyErr_SetString(PyExc_Exception,str.c_str());
00813         return -1;
00814     }
00815     catch(const Py::Exception&)
00816     {
00817         // The exception text is already set
00818         return -1;
00819     }
00820     catch(...)  // catch the rest!
00821     {
00822         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00823         return -1;
00824     }
00825 #else  // DONT_CATCH_CXX_EXCEPTIONS  
00826     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00827     {
00828         std::string str;
00829         str += "FreeCAD exception thrown (";
00830         str += e.what();
00831         str += ")";
00832         e.ReportException();
00833         PyErr_SetString(PyExc_Exception,str.c_str());
00834         return -1;
00835     }
00836     catch(const Py::Exception&)
00837     {
00838         // The exception text is already set
00839         return -1;
00840     }
00841 #endif  // DONT_CATCH_CXX_EXCEPTIONS
00842 
00843     return PyObjectBase::_setattr(attr, value);
00844 }
00845 
00846 Placement *PlacementPy::getPlacementPtr(void) const
00847 {
00848     return static_cast<Placement *>(_pcTwinPointer);
00849 }
00850 
00851 #if 0
00852 /* From here on come the methods you have to implement, but NOT in this module. Implement in PlacementPyImp.cpp! This prototypes 
00853  * are just for convenience when you add a new method.
00854  */
00855 
00856 PyObject *PlacementPy::PyMake(struct _typeobject *, PyObject *, PyObject *)  // Python wrapper
00857 {
00858     // create a new instance of PlacementPy and the Twin object 
00859     return new PlacementPy(new Placement);
00860 }
00861 
00862 // constructor method
00863 int PlacementPy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
00864 {
00865     return 0;
00866 }
00867 
00868 // returns a string which represents the object e.g. when printed in python
00869 std::string PlacementPy::representation(void) const
00870 {
00871     return std::string("<Placement object>");
00872 }
00873 
00874 PyObject* PlacementPy::copy(PyObject *args)
00875 {
00876     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
00877     return 0;
00878 }
00879 
00880 PyObject* PlacementPy::move(PyObject *args)
00881 {
00882     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
00883     return 0;
00884 }
00885 
00886 PyObject* PlacementPy::multiply(PyObject *args)
00887 {
00888     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
00889     return 0;
00890 }
00891 
00892 PyObject* PlacementPy::multVec(PyObject *args)
00893 {
00894     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
00895     return 0;
00896 }
00897 
00898 PyObject* PlacementPy::toMatrix(PyObject *args)
00899 {
00900     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
00901     return 0;
00902 }
00903 
00904 PyObject* PlacementPy::inverse(PyObject *args)
00905 {
00906     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
00907     return 0;
00908 }
00909 
00910 
00911 
00912 Py::Object PlacementPy::getBase(void) const
00913 {
00914     //return Py::Object();
00915     throw Py::AttributeError("Not yet implemented");
00916 }
00917 
00918 void  PlacementPy::setBase(Py::Object arg)
00919 {
00920     throw Py::AttributeError("Not yet implemented");
00921 }
00922 
00923 Py::Object PlacementPy::getRotation(void) const
00924 {
00925     //return Py::Object();
00926     throw Py::AttributeError("Not yet implemented");
00927 }
00928 
00929 void  PlacementPy::setRotation(Py::Object arg)
00930 {
00931     throw Py::AttributeError("Not yet implemented");
00932 }
00933 
00934 PyObject *PlacementPy::getCustomAttributes(const char* attr) const
00935 {
00936     return 0;
00937 }
00938 
00939 int PlacementPy::setCustomAttributes(const char* attr, PyObject *obj)
00940 {
00941     return 0; 
00942 }
00943 #endif
00944 
00945 
00946 

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