OffsetCurvePy.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 OffsetCurvePyImp.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 OffsetCurvePy::Type = {
00021     PyObject_HEAD_INIT(&PyType_Type)
00022     0,                                                /*ob_size*/
00023     "Part.GeomOffsetCurve",     /*tp_name*/
00024     sizeof(OffsetCurvePy),                       /*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     "",           /*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::OffsetCurvePy::Methods,                     /*tp_methods */
00053     0,                                                /*tp_members */
00054     Part::OffsetCurvePy::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::OffsetCurvePy::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 OffsetCurvePy::Methods[] = {
00075     {NULL, NULL, 0, NULL}               /* Sentinel */
00076 };
00077 
00078 
00079 
00081 PyGetSetDef OffsetCurvePy::GetterSetter[] = {
00082     {"OffsetValue",
00083         (getter) staticCallback_getOffsetValue,
00084         (setter) staticCallback_setOffsetValue, 
00085         "\n                                     Sets or gets the offset value to offset the underlying curve.\n                         ",
00086         NULL
00087     },
00088     {"OffsetDirection",
00089         (getter) staticCallback_getOffsetDirection,
00090         (setter) staticCallback_setOffsetDirection, 
00091         "\n                                     Sets or gets the offset direction to offset the underlying curve.\n                             ",
00092         NULL
00093     },
00094     {"BasisCurve",
00095         (getter) staticCallback_getBasisCurve,
00096         (setter) staticCallback_setBasisCurve, 
00097         "\n                                     Sets or gets the basic curve.\n                         ",
00098         NULL
00099     },
00100     {NULL, NULL, NULL, NULL, NULL}              /* Sentinel */
00101 };
00102 
00103 // OffsetValue() callback and implementer
00104 // PyObject*  OffsetCurvePy::OffsetValue(PyObject *args){};
00105 // has to be implemented in OffsetCurvePyImp.cpp
00106 PyObject * OffsetCurvePy::staticCallback_getOffsetValue (PyObject *self, void * /*closure*/)
00107 {
00108     if (!((PyObjectBase*) self)->isValid()){
00109         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00110         return NULL;
00111     }
00112 
00113     try {
00114         return Py::new_reference_to(((OffsetCurvePy*)self)->getOffsetValue());
00115     } catch (const Py::Exception&) {
00116         // The exception text is already set
00117         return NULL;
00118     } catch (...) {
00119         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'OffsetValue' of object 'GeomOffsetCurve'");
00120         return NULL;
00121     }
00122 }
00123 
00124 int OffsetCurvePy::staticCallback_setOffsetValue (PyObject *self, PyObject *value, 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 -1;
00129     }
00130     if (((PyObjectBase*) self)->isConst()){
00131         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
00132         return -1;
00133     }
00134 
00135     try {
00136         ((OffsetCurvePy*)self)->setOffsetValue(Py::Float(value,false));
00137         return 0;
00138     } catch (const Py::Exception&) {
00139         // The exception text is already set
00140         return -1;
00141     } catch (...) {
00142         PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'OffsetValue' of object 'GeomOffsetCurve'");
00143         return -1;
00144     }
00145 }
00146 
00147 // OffsetDirection() callback and implementer
00148 // PyObject*  OffsetCurvePy::OffsetDirection(PyObject *args){};
00149 // has to be implemented in OffsetCurvePyImp.cpp
00150 PyObject * OffsetCurvePy::staticCallback_getOffsetDirection (PyObject *self, void * /*closure*/)
00151 {
00152     if (!((PyObjectBase*) self)->isValid()){
00153         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00154         return NULL;
00155     }
00156 
00157     try {
00158         return Py::new_reference_to(((OffsetCurvePy*)self)->getOffsetDirection());
00159     } catch (const Py::Exception&) {
00160         // The exception text is already set
00161         return NULL;
00162     } catch (...) {
00163         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'OffsetDirection' of object 'GeomOffsetCurve'");
00164         return NULL;
00165     }
00166 }
00167 
00168 int OffsetCurvePy::staticCallback_setOffsetDirection (PyObject *self, PyObject *value, void * /*closure*/)
00169 {    
00170     if (!((PyObjectBase*) self)->isValid()){
00171         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00172         return -1;
00173     }
00174     if (((PyObjectBase*) self)->isConst()){
00175         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
00176         return -1;
00177     }
00178 
00179     try {
00180         ((OffsetCurvePy*)self)->setOffsetDirection(Py::Object(value,false));
00181         return 0;
00182     } catch (const Py::Exception&) {
00183         // The exception text is already set
00184         return -1;
00185     } catch (...) {
00186         PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'OffsetDirection' of object 'GeomOffsetCurve'");
00187         return -1;
00188     }
00189 }
00190 
00191 // BasisCurve() callback and implementer
00192 // PyObject*  OffsetCurvePy::BasisCurve(PyObject *args){};
00193 // has to be implemented in OffsetCurvePyImp.cpp
00194 PyObject * OffsetCurvePy::staticCallback_getBasisCurve (PyObject *self, void * /*closure*/)
00195 {
00196     if (!((PyObjectBase*) self)->isValid()){
00197         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00198         return NULL;
00199     }
00200 
00201     try {
00202         return Py::new_reference_to(((OffsetCurvePy*)self)->getBasisCurve());
00203     } catch (const Py::Exception&) {
00204         // The exception text is already set
00205         return NULL;
00206     } catch (...) {
00207         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'BasisCurve' of object 'GeomOffsetCurve'");
00208         return NULL;
00209     }
00210 }
00211 
00212 int OffsetCurvePy::staticCallback_setBasisCurve (PyObject *self, PyObject *value, void * /*closure*/)
00213 {    
00214     if (!((PyObjectBase*) self)->isValid()){
00215         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00216         return -1;
00217     }
00218     if (((PyObjectBase*) self)->isConst()){
00219         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
00220         return -1;
00221     }
00222 
00223     try {
00224         ((OffsetCurvePy*)self)->setBasisCurve(Py::Object(value,false));
00225         return 0;
00226     } catch (const Py::Exception&) {
00227         // The exception text is already set
00228         return -1;
00229     } catch (...) {
00230         PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'BasisCurve' of object 'GeomOffsetCurve'");
00231         return -1;
00232     }
00233 }
00234 
00235 
00236 
00237 //--------------------------------------------------------------------------
00238 // Parents structure
00239 //--------------------------------------------------------------------------
00240 PyParentObject OffsetCurvePy::Parents[] = { PARENTSPartOffsetCurvePy };
00241 
00242 //--------------------------------------------------------------------------
00243 // Constructor
00244 //--------------------------------------------------------------------------
00245 OffsetCurvePy::OffsetCurvePy(GeomOffsetCurve *pcObject, PyTypeObject *T)
00246     : GeometryCurvePy(reinterpret_cast<GeometryCurvePy::PointerType>(pcObject), T)
00247 {
00248 }
00249 
00250 
00251 //--------------------------------------------------------------------------
00252 // destructor
00253 //--------------------------------------------------------------------------
00254 OffsetCurvePy::~OffsetCurvePy()                                // Everything handled in parent
00255 {
00256 }
00257 
00258 //--------------------------------------------------------------------------
00259 // OffsetCurvePy representation
00260 //--------------------------------------------------------------------------
00261 PyObject *OffsetCurvePy::_repr(void)
00262 {
00263     return Py_BuildValue("s", representation().c_str());
00264 }
00265 
00266 //--------------------------------------------------------------------------
00267 // OffsetCurvePy Attributes
00268 //--------------------------------------------------------------------------
00269 PyObject *OffsetCurvePy::_getattr(char *attr)                           // __getattr__ function: note only need to handle new state
00270 {
00271     try {
00272         // getter method for special Attributes (e.g. dynamic ones)
00273         PyObject *r = getCustomAttributes(attr);
00274         if(r) return r;
00275     }
00276 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00277     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00278     {
00279         std::string str;
00280         str += "FreeCAD exception thrown (";
00281         str += e.what();
00282         str += ")";
00283         e.ReportException();
00284         PyErr_SetString(PyExc_Exception,str.c_str());
00285         return NULL;
00286     }
00287     catch(const std::exception& e) // catch other c++ exceptions
00288     {
00289         std::string str;
00290         str += "FC++ exception thrown (";
00291         str += e.what();
00292         str += ")";
00293         Base::Console().Error(str.c_str());
00294         PyErr_SetString(PyExc_Exception,str.c_str());
00295         return NULL;
00296     }
00297     catch(const Py::Exception&)
00298     {
00299         // The exception text is already set
00300         return NULL;
00301     }
00302     catch(...)  // catch the rest!
00303     {
00304         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00305         return NULL;
00306     }
00307 #else  // DONT_CATCH_CXX_EXCEPTIONS  
00308     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00309     {
00310         std::string str;
00311         str += "FreeCAD exception thrown (";
00312         str += e.what();
00313         str += ")";
00314         e.ReportException();
00315         PyErr_SetString(PyExc_Exception,str.c_str());
00316         return NULL;
00317     }
00318     catch(const Py::Exception&)
00319     {
00320         // The exception text is already set
00321         return NULL;
00322     }
00323 #endif  // DONT_CATCH_CXX_EXCEPTIONS
00324 
00325     PyObject *rvalue = Py_FindMethod(Methods, this, attr);
00326     if (rvalue == NULL)
00327     {
00328         PyErr_Clear();
00329         return GeometryCurvePy::_getattr(attr);
00330     }
00331     else
00332     {
00333         return rvalue;
00334     }
00335 }
00336 
00337 int OffsetCurvePy::_setattr(char *attr, PyObject *value)        // __setattr__ function: note only need to handle new state
00338 {
00339     try {
00340         // setter for  special Attributes (e.g. dynamic ones)
00341         int r = setCustomAttributes(attr, value);
00342         if(r==1) return 0;
00343     }
00344 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00345     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00346     {
00347         std::string str;
00348         str += "FreeCAD exception thrown (";
00349         str += e.what();
00350         str += ")";
00351         e.ReportException();
00352         PyErr_SetString(PyExc_Exception,str.c_str());
00353         return -1;
00354     }
00355     catch(const std::exception& e) // catch other c++ exceptions
00356     {
00357         std::string str;
00358         str += "FC++ exception thrown (";
00359         str += e.what();
00360         str += ")";
00361         Base::Console().Error(str.c_str());
00362         PyErr_SetString(PyExc_Exception,str.c_str());
00363         return -1;
00364     }
00365     catch(const Py::Exception&)
00366     {
00367         // The exception text is already set
00368         return -1;
00369     }
00370     catch(...)  // catch the rest!
00371     {
00372         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00373         return -1;
00374     }
00375 #else  // DONT_CATCH_CXX_EXCEPTIONS  
00376     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00377     {
00378         std::string str;
00379         str += "FreeCAD exception thrown (";
00380         str += e.what();
00381         str += ")";
00382         e.ReportException();
00383         PyErr_SetString(PyExc_Exception,str.c_str());
00384         return -1;
00385     }
00386     catch(const Py::Exception&)
00387     {
00388         // The exception text is already set
00389         return -1;
00390     }
00391 #endif  // DONT_CATCH_CXX_EXCEPTIONS
00392 
00393     return GeometryCurvePy::_setattr(attr, value);
00394 }
00395 
00396 GeomOffsetCurve *OffsetCurvePy::getGeomOffsetCurvePtr(void) const
00397 {
00398     return static_cast<GeomOffsetCurve *>(_pcTwinPointer);
00399 }
00400 
00401 #if 0
00402 /* From here on come the methods you have to implement, but NOT in this module. Implement in OffsetCurvePyImp.cpp! This prototypes 
00403  * are just for convenience when you add a new method.
00404  */
00405 
00406 PyObject *OffsetCurvePy::PyMake(struct _typeobject *, PyObject *, PyObject *)  // Python wrapper
00407 {
00408     // create a new instance of OffsetCurvePy and the Twin object 
00409     return new OffsetCurvePy(new GeomOffsetCurve);
00410 }
00411 
00412 // constructor method
00413 int OffsetCurvePy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
00414 {
00415     return 0;
00416 }
00417 
00418 // returns a string which represents the object e.g. when printed in python
00419 std::string OffsetCurvePy::representation(void) const
00420 {
00421     return std::string("<GeomOffsetCurve object>");
00422 }
00423 
00424 
00425 
00426 Py::Float OffsetCurvePy::getOffsetValue(void) const
00427 {
00428     //return Py::Float();
00429     throw Py::AttributeError("Not yet implemented");
00430 }
00431 
00432 void  OffsetCurvePy::setOffsetValue(Py::Float arg)
00433 {
00434     throw Py::AttributeError("Not yet implemented");
00435 }
00436 
00437 Py::Object OffsetCurvePy::getOffsetDirection(void) const
00438 {
00439     //return Py::Object();
00440     throw Py::AttributeError("Not yet implemented");
00441 }
00442 
00443 void  OffsetCurvePy::setOffsetDirection(Py::Object arg)
00444 {
00445     throw Py::AttributeError("Not yet implemented");
00446 }
00447 
00448 Py::Object OffsetCurvePy::getBasisCurve(void) const
00449 {
00450     //return Py::Object();
00451     throw Py::AttributeError("Not yet implemented");
00452 }
00453 
00454 void  OffsetCurvePy::setBasisCurve(Py::Object arg)
00455 {
00456     throw Py::AttributeError("Not yet implemented");
00457 }
00458 
00459 PyObject *OffsetCurvePy::getCustomAttributes(const char* attr) const
00460 {
00461     return 0;
00462 }
00463 
00464 int OffsetCurvePy::setCustomAttributes(const char* attr, PyObject *obj)
00465 {
00466     return 0; 
00467 }
00468 #endif
00469 
00470 
00471 

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