ParabolaPy.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 ParabolaPyImp.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 Part;
00018 
00020 PyTypeObject ParabolaPy::Type = {
00021     PyObject_HEAD_INIT(&PyType_Type)
00022     0,                                                /*ob_size*/
00023     "Part.GeomParabola",     /*tp_name*/
00024     sizeof(ParabolaPy),                       /*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     "Describes a parabola in 3D space",           /*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     Part::ParabolaPy::Methods,                     /*tp_methods */
00053     0,                                                /*tp_members */
00054     Part::ParabolaPy::GetterSetter,                     /*tp_getset */
00055     &Part::GeometryCurvePy::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     Part::ParabolaPy::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 ParabolaPy::Methods[] = {
00075     {NULL, NULL, 0, NULL}               /* Sentinel */
00076 };
00077 
00078 
00079 
00081 PyGetSetDef ParabolaPy::GetterSetter[] = {
00082     {"Eccentricity",
00083         (getter) staticCallback_getEccentricity,
00084         (setter) staticCallback_setEccentricity, 
00085         "Returns 1. (which is the eccentricity of any parabola).",
00086         NULL
00087     },
00088     {"Focal",
00089         (getter) staticCallback_getFocal,
00090         (setter) staticCallback_setFocal, 
00091         "The focal distance is the distance between\nthe apex and the focus of the parabola.",
00092         NULL
00093     },
00094     {"Focus",
00095         (getter) staticCallback_getFocus,
00096         (setter) staticCallback_setFocus, 
00097         "The focus is on the positive side of the\n'X Axis' of the local coordinate system of the parabola.",
00098         NULL
00099     },
00100     {"Parameter",
00101         (getter) staticCallback_getParameter,
00102         (setter) staticCallback_setParameter, 
00103         "Compute the parameter of this parabola\nwhich is the distance between its focus\nand its directrix. This distance is twice the focal length.\n                         ",
00104         NULL
00105     },
00106     {"Location",
00107         (getter) staticCallback_getLocation,
00108         (setter) staticCallback_setLocation, 
00109         "Location of the parabola",
00110         NULL
00111     },
00112     {"Axis",
00113         (getter) staticCallback_getAxis,
00114         (setter) staticCallback_setAxis, 
00115         "The axis direction of the parabola",
00116         NULL
00117     },
00118     {NULL, NULL, NULL, NULL, NULL}              /* Sentinel */
00119 };
00120 
00121 // Eccentricity() callback and implementer
00122 // PyObject*  ParabolaPy::Eccentricity(PyObject *args){};
00123 // has to be implemented in ParabolaPyImp.cpp
00124 PyObject * ParabolaPy::staticCallback_getEccentricity (PyObject *self, void * /*closure*/)
00125 {
00126     if (!((PyObjectBase*) self)->isValid()){
00127         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00128         return NULL;
00129     }
00130 
00131     try {
00132         return Py::new_reference_to(((ParabolaPy*)self)->getEccentricity());
00133     } catch (const Py::Exception&) {
00134         // The exception text is already set
00135         return NULL;
00136     } catch (...) {
00137         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Eccentricity' of object 'GeomParabola'");
00138         return NULL;
00139     }
00140 }
00141 
00142 int ParabolaPy::staticCallback_setEccentricity (PyObject *self, PyObject * /*value*/, void * /*closure*/)
00143 {
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 -1;
00147     }
00148 
00149     PyErr_SetString(PyExc_AttributeError, "Attribute 'Eccentricity' of object 'GeomParabola' is read-only");
00150     return -1;
00151 }
00152 
00153 // Focal() callback and implementer
00154 // PyObject*  ParabolaPy::Focal(PyObject *args){};
00155 // has to be implemented in ParabolaPyImp.cpp
00156 PyObject * ParabolaPy::staticCallback_getFocal (PyObject *self, void * /*closure*/)
00157 {
00158     if (!((PyObjectBase*) self)->isValid()){
00159         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00160         return NULL;
00161     }
00162 
00163     try {
00164         return Py::new_reference_to(((ParabolaPy*)self)->getFocal());
00165     } catch (const Py::Exception&) {
00166         // The exception text is already set
00167         return NULL;
00168     } catch (...) {
00169         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Focal' of object 'GeomParabola'");
00170         return NULL;
00171     }
00172 }
00173 
00174 int ParabolaPy::staticCallback_setFocal (PyObject *self, PyObject *value, void * /*closure*/)
00175 {    
00176     if (!((PyObjectBase*) self)->isValid()){
00177         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00178         return -1;
00179     }
00180     if (((PyObjectBase*) self)->isConst()){
00181         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
00182         return -1;
00183     }
00184 
00185     try {
00186         ((ParabolaPy*)self)->setFocal(Py::Float(value,false));
00187         return 0;
00188     } catch (const Py::Exception&) {
00189         // The exception text is already set
00190         return -1;
00191     } catch (...) {
00192         PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'Focal' of object 'GeomParabola'");
00193         return -1;
00194     }
00195 }
00196 
00197 // Focus() callback and implementer
00198 // PyObject*  ParabolaPy::Focus(PyObject *args){};
00199 // has to be implemented in ParabolaPyImp.cpp
00200 PyObject * ParabolaPy::staticCallback_getFocus (PyObject *self, void * /*closure*/)
00201 {
00202     if (!((PyObjectBase*) self)->isValid()){
00203         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00204         return NULL;
00205     }
00206 
00207     try {
00208         return Py::new_reference_to(((ParabolaPy*)self)->getFocus());
00209     } catch (const Py::Exception&) {
00210         // The exception text is already set
00211         return NULL;
00212     } catch (...) {
00213         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Focus' of object 'GeomParabola'");
00214         return NULL;
00215     }
00216 }
00217 
00218 int ParabolaPy::staticCallback_setFocus (PyObject *self, PyObject * /*value*/, void * /*closure*/)
00219 {
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 -1;
00223     }
00224 
00225     PyErr_SetString(PyExc_AttributeError, "Attribute 'Focus' of object 'GeomParabola' is read-only");
00226     return -1;
00227 }
00228 
00229 // Parameter() callback and implementer
00230 // PyObject*  ParabolaPy::Parameter(PyObject *args){};
00231 // has to be implemented in ParabolaPyImp.cpp
00232 PyObject * ParabolaPy::staticCallback_getParameter (PyObject *self, void * /*closure*/)
00233 {
00234     if (!((PyObjectBase*) self)->isValid()){
00235         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00236         return NULL;
00237     }
00238 
00239     try {
00240         return Py::new_reference_to(((ParabolaPy*)self)->getParameter());
00241     } catch (const Py::Exception&) {
00242         // The exception text is already set
00243         return NULL;
00244     } catch (...) {
00245         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Parameter' of object 'GeomParabola'");
00246         return NULL;
00247     }
00248 }
00249 
00250 int ParabolaPy::staticCallback_setParameter (PyObject *self, PyObject * /*value*/, void * /*closure*/)
00251 {
00252     if (!((PyObjectBase*) self)->isValid()){
00253         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00254         return -1;
00255     }
00256 
00257     PyErr_SetString(PyExc_AttributeError, "Attribute 'Parameter' of object 'GeomParabola' is read-only");
00258     return -1;
00259 }
00260 
00261 // Location() callback and implementer
00262 // PyObject*  ParabolaPy::Location(PyObject *args){};
00263 // has to be implemented in ParabolaPyImp.cpp
00264 PyObject * ParabolaPy::staticCallback_getLocation (PyObject *self, void * /*closure*/)
00265 {
00266     if (!((PyObjectBase*) self)->isValid()){
00267         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00268         return NULL;
00269     }
00270 
00271     try {
00272         return Py::new_reference_to(((ParabolaPy*)self)->getLocation());
00273     } catch (const Py::Exception&) {
00274         // The exception text is already set
00275         return NULL;
00276     } catch (...) {
00277         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Location' of object 'GeomParabola'");
00278         return NULL;
00279     }
00280 }
00281 
00282 int ParabolaPy::staticCallback_setLocation (PyObject *self, PyObject *value, void * /*closure*/)
00283 {    
00284     if (!((PyObjectBase*) self)->isValid()){
00285         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00286         return -1;
00287     }
00288     if (((PyObjectBase*) self)->isConst()){
00289         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
00290         return -1;
00291     }
00292 
00293     try {
00294         ((ParabolaPy*)self)->setLocation(Py::Object(value,false));
00295         return 0;
00296     } catch (const Py::Exception&) {
00297         // The exception text is already set
00298         return -1;
00299     } catch (...) {
00300         PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'Location' of object 'GeomParabola'");
00301         return -1;
00302     }
00303 }
00304 
00305 // Axis() callback and implementer
00306 // PyObject*  ParabolaPy::Axis(PyObject *args){};
00307 // has to be implemented in ParabolaPyImp.cpp
00308 PyObject * ParabolaPy::staticCallback_getAxis (PyObject *self, void * /*closure*/)
00309 {
00310     if (!((PyObjectBase*) self)->isValid()){
00311         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00312         return NULL;
00313     }
00314 
00315     try {
00316         return Py::new_reference_to(((ParabolaPy*)self)->getAxis());
00317     } catch (const Py::Exception&) {
00318         // The exception text is already set
00319         return NULL;
00320     } catch (...) {
00321         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Axis' of object 'GeomParabola'");
00322         return NULL;
00323     }
00324 }
00325 
00326 int ParabolaPy::staticCallback_setAxis (PyObject *self, PyObject *value, void * /*closure*/)
00327 {    
00328     if (!((PyObjectBase*) self)->isValid()){
00329         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00330         return -1;
00331     }
00332     if (((PyObjectBase*) self)->isConst()){
00333         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
00334         return -1;
00335     }
00336 
00337     try {
00338         ((ParabolaPy*)self)->setAxis(Py::Object(value,false));
00339         return 0;
00340     } catch (const Py::Exception&) {
00341         // The exception text is already set
00342         return -1;
00343     } catch (...) {
00344         PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'Axis' of object 'GeomParabola'");
00345         return -1;
00346     }
00347 }
00348 
00349 
00350 
00351 //--------------------------------------------------------------------------
00352 // Parents structure
00353 //--------------------------------------------------------------------------
00354 PyParentObject ParabolaPy::Parents[] = { PARENTSPartParabolaPy };
00355 
00356 //--------------------------------------------------------------------------
00357 // Constructor
00358 //--------------------------------------------------------------------------
00359 ParabolaPy::ParabolaPy(GeomParabola *pcObject, PyTypeObject *T)
00360     : GeometryCurvePy(reinterpret_cast<GeometryCurvePy::PointerType>(pcObject), T)
00361 {
00362 }
00363 
00364 
00365 //--------------------------------------------------------------------------
00366 // destructor
00367 //--------------------------------------------------------------------------
00368 ParabolaPy::~ParabolaPy()                                // Everything handled in parent
00369 {
00370 }
00371 
00372 //--------------------------------------------------------------------------
00373 // ParabolaPy representation
00374 //--------------------------------------------------------------------------
00375 PyObject *ParabolaPy::_repr(void)
00376 {
00377     return Py_BuildValue("s", representation().c_str());
00378 }
00379 
00380 //--------------------------------------------------------------------------
00381 // ParabolaPy Attributes
00382 //--------------------------------------------------------------------------
00383 PyObject *ParabolaPy::_getattr(char *attr)                              // __getattr__ function: note only need to handle new state
00384 {
00385     try {
00386         // getter method for special Attributes (e.g. dynamic ones)
00387         PyObject *r = getCustomAttributes(attr);
00388         if(r) return r;
00389     }
00390 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00391     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00392     {
00393         std::string str;
00394         str += "FreeCAD exception thrown (";
00395         str += e.what();
00396         str += ")";
00397         e.ReportException();
00398         PyErr_SetString(PyExc_Exception,str.c_str());
00399         return NULL;
00400     }
00401     catch(const std::exception& e) // catch other c++ exceptions
00402     {
00403         std::string str;
00404         str += "FC++ exception thrown (";
00405         str += e.what();
00406         str += ")";
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(...)  // catch the rest!
00417     {
00418         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00419         return NULL;
00420     }
00421 #else  // DONT_CATCH_CXX_EXCEPTIONS  
00422     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00423     {
00424         std::string str;
00425         str += "FreeCAD exception thrown (";
00426         str += e.what();
00427         str += ")";
00428         e.ReportException();
00429         PyErr_SetString(PyExc_Exception,str.c_str());
00430         return NULL;
00431     }
00432     catch(const Py::Exception&)
00433     {
00434         // The exception text is already set
00435         return NULL;
00436     }
00437 #endif  // DONT_CATCH_CXX_EXCEPTIONS
00438 
00439     PyObject *rvalue = Py_FindMethod(Methods, this, attr);
00440     if (rvalue == NULL)
00441     {
00442         PyErr_Clear();
00443         return GeometryCurvePy::_getattr(attr);
00444     }
00445     else
00446     {
00447         return rvalue;
00448     }
00449 }
00450 
00451 int ParabolaPy::_setattr(char *attr, PyObject *value)   // __setattr__ function: note only need to handle new state
00452 {
00453     try {
00454         // setter for  special Attributes (e.g. dynamic ones)
00455         int r = setCustomAttributes(attr, value);
00456         if(r==1) return 0;
00457     }
00458 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00459     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00460     {
00461         std::string str;
00462         str += "FreeCAD exception thrown (";
00463         str += e.what();
00464         str += ")";
00465         e.ReportException();
00466         PyErr_SetString(PyExc_Exception,str.c_str());
00467         return -1;
00468     }
00469     catch(const std::exception& e) // catch other c++ exceptions
00470     {
00471         std::string str;
00472         str += "FC++ exception thrown (";
00473         str += e.what();
00474         str += ")";
00475         Base::Console().Error(str.c_str());
00476         PyErr_SetString(PyExc_Exception,str.c_str());
00477         return -1;
00478     }
00479     catch(const Py::Exception&)
00480     {
00481         // The exception text is already set
00482         return -1;
00483     }
00484     catch(...)  // catch the rest!
00485     {
00486         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00487         return -1;
00488     }
00489 #else  // DONT_CATCH_CXX_EXCEPTIONS  
00490     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00491     {
00492         std::string str;
00493         str += "FreeCAD exception thrown (";
00494         str += e.what();
00495         str += ")";
00496         e.ReportException();
00497         PyErr_SetString(PyExc_Exception,str.c_str());
00498         return -1;
00499     }
00500     catch(const Py::Exception&)
00501     {
00502         // The exception text is already set
00503         return -1;
00504     }
00505 #endif  // DONT_CATCH_CXX_EXCEPTIONS
00506 
00507     return GeometryCurvePy::_setattr(attr, value);
00508 }
00509 
00510 GeomParabola *ParabolaPy::getGeomParabolaPtr(void) const
00511 {
00512     return static_cast<GeomParabola *>(_pcTwinPointer);
00513 }
00514 
00515 #if 0
00516 /* From here on come the methods you have to implement, but NOT in this module. Implement in ParabolaPyImp.cpp! This prototypes 
00517  * are just for convenience when you add a new method.
00518  */
00519 
00520 PyObject *ParabolaPy::PyMake(struct _typeobject *, PyObject *, PyObject *)  // Python wrapper
00521 {
00522     // create a new instance of ParabolaPy and the Twin object 
00523     return new ParabolaPy(new GeomParabola);
00524 }
00525 
00526 // constructor method
00527 int ParabolaPy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
00528 {
00529     return 0;
00530 }
00531 
00532 // returns a string which represents the object e.g. when printed in python
00533 std::string ParabolaPy::representation(void) const
00534 {
00535     return std::string("<GeomParabola object>");
00536 }
00537 
00538 
00539 
00540 Py::Float ParabolaPy::getEccentricity(void) const
00541 {
00542     //return Py::Float();
00543     throw Py::AttributeError("Not yet implemented");
00544 }
00545 
00546 Py::Float ParabolaPy::getFocal(void) const
00547 {
00548     //return Py::Float();
00549     throw Py::AttributeError("Not yet implemented");
00550 }
00551 
00552 void  ParabolaPy::setFocal(Py::Float arg)
00553 {
00554     throw Py::AttributeError("Not yet implemented");
00555 }
00556 
00557 Py::Object ParabolaPy::getFocus(void) const
00558 {
00559     //return Py::Object();
00560     throw Py::AttributeError("Not yet implemented");
00561 }
00562 
00563 Py::Float ParabolaPy::getParameter(void) const
00564 {
00565     //return Py::Float();
00566     throw Py::AttributeError("Not yet implemented");
00567 }
00568 
00569 Py::Object ParabolaPy::getLocation(void) const
00570 {
00571     //return Py::Object();
00572     throw Py::AttributeError("Not yet implemented");
00573 }
00574 
00575 void  ParabolaPy::setLocation(Py::Object arg)
00576 {
00577     throw Py::AttributeError("Not yet implemented");
00578 }
00579 
00580 Py::Object ParabolaPy::getAxis(void) const
00581 {
00582     //return Py::Object();
00583     throw Py::AttributeError("Not yet implemented");
00584 }
00585 
00586 void  ParabolaPy::setAxis(Py::Object arg)
00587 {
00588     throw Py::AttributeError("Not yet implemented");
00589 }
00590 
00591 PyObject *ParabolaPy::getCustomAttributes(const char* attr) const
00592 {
00593     return 0;
00594 }
00595 
00596 int ParabolaPy::setCustomAttributes(const char* attr, PyObject *obj)
00597 {
00598     return 0; 
00599 }
00600 #endif
00601 
00602 
00603 

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