ArcOfCirclePy.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 ArcOfCirclePyImp.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 ArcOfCirclePy::Type = {
00021     PyObject_HEAD_INIT(&PyType_Type)
00022     0,                                                /*ob_size*/
00023     "Part.GeomArcOfCircle",     /*tp_name*/
00024     sizeof(ArcOfCirclePy),                       /*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 portion of a circle",           /*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::ArcOfCirclePy::Methods,                     /*tp_methods */
00053     0,                                                /*tp_members */
00054     Part::ArcOfCirclePy::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::ArcOfCirclePy::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 ArcOfCirclePy::Methods[] = {
00075     {NULL, NULL, 0, NULL}               /* Sentinel */
00076 };
00077 
00078 
00079 
00081 PyGetSetDef ArcOfCirclePy::GetterSetter[] = {
00082     {"Radius",
00083         (getter) staticCallback_getRadius,
00084         (setter) staticCallback_setRadius, 
00085         "The radius of the circle.",
00086         NULL
00087     },
00088     {"Center",
00089         (getter) staticCallback_getCenter,
00090         (setter) staticCallback_setCenter, 
00091         "Center of the circle.",
00092         NULL
00093     },
00094     {"Axis",
00095         (getter) staticCallback_getAxis,
00096         (setter) staticCallback_setAxis, 
00097         "The axis direction of the circle",
00098         NULL
00099     },
00100     {"Circle",
00101         (getter) staticCallback_getCircle,
00102         (setter) staticCallback_setCircle, 
00103         "The internal circle representation",
00104         NULL
00105     },
00106     {NULL, NULL, NULL, NULL, NULL}              /* Sentinel */
00107 };
00108 
00109 // Radius() callback and implementer
00110 // PyObject*  ArcOfCirclePy::Radius(PyObject *args){};
00111 // has to be implemented in ArcOfCirclePyImp.cpp
00112 PyObject * ArcOfCirclePy::staticCallback_getRadius (PyObject *self, void * /*closure*/)
00113 {
00114     if (!((PyObjectBase*) self)->isValid()){
00115         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00116         return NULL;
00117     }
00118 
00119     try {
00120         return Py::new_reference_to(((ArcOfCirclePy*)self)->getRadius());
00121     } catch (const Py::Exception&) {
00122         // The exception text is already set
00123         return NULL;
00124     } catch (...) {
00125         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Radius' of object 'GeomArcOfCircle'");
00126         return NULL;
00127     }
00128 }
00129 
00130 int ArcOfCirclePy::staticCallback_setRadius (PyObject *self, PyObject *value, void * /*closure*/)
00131 {    
00132     if (!((PyObjectBase*) self)->isValid()){
00133         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00134         return -1;
00135     }
00136     if (((PyObjectBase*) self)->isConst()){
00137         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
00138         return -1;
00139     }
00140 
00141     try {
00142         ((ArcOfCirclePy*)self)->setRadius(Py::Float(value,false));
00143         return 0;
00144     } catch (const Py::Exception&) {
00145         // The exception text is already set
00146         return -1;
00147     } catch (...) {
00148         PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'Radius' of object 'GeomArcOfCircle'");
00149         return -1;
00150     }
00151 }
00152 
00153 // Center() callback and implementer
00154 // PyObject*  ArcOfCirclePy::Center(PyObject *args){};
00155 // has to be implemented in ArcOfCirclePyImp.cpp
00156 PyObject * ArcOfCirclePy::staticCallback_getCenter (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(((ArcOfCirclePy*)self)->getCenter());
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 'Center' of object 'GeomArcOfCircle'");
00170         return NULL;
00171     }
00172 }
00173 
00174 int ArcOfCirclePy::staticCallback_setCenter (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         ((ArcOfCirclePy*)self)->setCenter(Py::Object(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 'Center' of object 'GeomArcOfCircle'");
00193         return -1;
00194     }
00195 }
00196 
00197 // Axis() callback and implementer
00198 // PyObject*  ArcOfCirclePy::Axis(PyObject *args){};
00199 // has to be implemented in ArcOfCirclePyImp.cpp
00200 PyObject * ArcOfCirclePy::staticCallback_getAxis (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(((ArcOfCirclePy*)self)->getAxis());
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 'Axis' of object 'GeomArcOfCircle'");
00214         return NULL;
00215     }
00216 }
00217 
00218 int ArcOfCirclePy::staticCallback_setAxis (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     if (((PyObjectBase*) self)->isConst()){
00225         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
00226         return -1;
00227     }
00228 
00229     try {
00230         ((ArcOfCirclePy*)self)->setAxis(Py::Object(value,false));
00231         return 0;
00232     } catch (const Py::Exception&) {
00233         // The exception text is already set
00234         return -1;
00235     } catch (...) {
00236         PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'Axis' of object 'GeomArcOfCircle'");
00237         return -1;
00238     }
00239 }
00240 
00241 // Circle() callback and implementer
00242 // PyObject*  ArcOfCirclePy::Circle(PyObject *args){};
00243 // has to be implemented in ArcOfCirclePyImp.cpp
00244 PyObject * ArcOfCirclePy::staticCallback_getCircle (PyObject *self, void * /*closure*/)
00245 {
00246     if (!((PyObjectBase*) self)->isValid()){
00247         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00248         return NULL;
00249     }
00250 
00251     try {
00252         return Py::new_reference_to(((ArcOfCirclePy*)self)->getCircle());
00253     } catch (const Py::Exception&) {
00254         // The exception text is already set
00255         return NULL;
00256     } catch (...) {
00257         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Circle' of object 'GeomArcOfCircle'");
00258         return NULL;
00259     }
00260 }
00261 
00262 int ArcOfCirclePy::staticCallback_setCircle (PyObject *self, PyObject * /*value*/, void * /*closure*/)
00263 {
00264     if (!((PyObjectBase*) self)->isValid()){
00265         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00266         return -1;
00267     }
00268 
00269     PyErr_SetString(PyExc_AttributeError, "Attribute 'Circle' of object 'GeomArcOfCircle' is read-only");
00270     return -1;
00271 }
00272 
00273 
00274 
00275 //--------------------------------------------------------------------------
00276 // Parents structure
00277 //--------------------------------------------------------------------------
00278 PyParentObject ArcOfCirclePy::Parents[] = { PARENTSPartArcOfCirclePy };
00279 
00280 //--------------------------------------------------------------------------
00281 // Constructor
00282 //--------------------------------------------------------------------------
00283 ArcOfCirclePy::ArcOfCirclePy(GeomArcOfCircle *pcObject, PyTypeObject *T)
00284     : GeometryCurvePy(reinterpret_cast<GeometryCurvePy::PointerType>(pcObject), T)
00285 {
00286 }
00287 
00288 
00289 //--------------------------------------------------------------------------
00290 // destructor
00291 //--------------------------------------------------------------------------
00292 ArcOfCirclePy::~ArcOfCirclePy()                                // Everything handled in parent
00293 {
00294 }
00295 
00296 //--------------------------------------------------------------------------
00297 // ArcOfCirclePy representation
00298 //--------------------------------------------------------------------------
00299 PyObject *ArcOfCirclePy::_repr(void)
00300 {
00301     return Py_BuildValue("s", representation().c_str());
00302 }
00303 
00304 //--------------------------------------------------------------------------
00305 // ArcOfCirclePy Attributes
00306 //--------------------------------------------------------------------------
00307 PyObject *ArcOfCirclePy::_getattr(char *attr)                           // __getattr__ function: note only need to handle new state
00308 {
00309     try {
00310         // getter method for special Attributes (e.g. dynamic ones)
00311         PyObject *r = getCustomAttributes(attr);
00312         if(r) return r;
00313     }
00314 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00315     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00316     {
00317         std::string str;
00318         str += "FreeCAD exception thrown (";
00319         str += e.what();
00320         str += ")";
00321         e.ReportException();
00322         PyErr_SetString(PyExc_Exception,str.c_str());
00323         return NULL;
00324     }
00325     catch(const std::exception& e) // catch other c++ exceptions
00326     {
00327         std::string str;
00328         str += "FC++ exception thrown (";
00329         str += e.what();
00330         str += ")";
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(...)  // catch the rest!
00341     {
00342         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00343         return NULL;
00344     }
00345 #else  // DONT_CATCH_CXX_EXCEPTIONS  
00346     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00347     {
00348         std::string str;
00349         str += "FreeCAD exception thrown (";
00350         str += e.what();
00351         str += ")";
00352         e.ReportException();
00353         PyErr_SetString(PyExc_Exception,str.c_str());
00354         return NULL;
00355     }
00356     catch(const Py::Exception&)
00357     {
00358         // The exception text is already set
00359         return NULL;
00360     }
00361 #endif  // DONT_CATCH_CXX_EXCEPTIONS
00362 
00363     PyObject *rvalue = Py_FindMethod(Methods, this, attr);
00364     if (rvalue == NULL)
00365     {
00366         PyErr_Clear();
00367         return GeometryCurvePy::_getattr(attr);
00368     }
00369     else
00370     {
00371         return rvalue;
00372     }
00373 }
00374 
00375 int ArcOfCirclePy::_setattr(char *attr, PyObject *value)        // __setattr__ function: note only need to handle new state
00376 {
00377     try {
00378         // setter for  special Attributes (e.g. dynamic ones)
00379         int r = setCustomAttributes(attr, value);
00380         if(r==1) return 0;
00381     }
00382 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00383     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00384     {
00385         std::string str;
00386         str += "FreeCAD exception thrown (";
00387         str += e.what();
00388         str += ")";
00389         e.ReportException();
00390         PyErr_SetString(PyExc_Exception,str.c_str());
00391         return -1;
00392     }
00393     catch(const std::exception& e) // catch other c++ exceptions
00394     {
00395         std::string str;
00396         str += "FC++ exception thrown (";
00397         str += e.what();
00398         str += ")";
00399         Base::Console().Error(str.c_str());
00400         PyErr_SetString(PyExc_Exception,str.c_str());
00401         return -1;
00402     }
00403     catch(const Py::Exception&)
00404     {
00405         // The exception text is already set
00406         return -1;
00407     }
00408     catch(...)  // catch the rest!
00409     {
00410         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00411         return -1;
00412     }
00413 #else  // DONT_CATCH_CXX_EXCEPTIONS  
00414     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00415     {
00416         std::string str;
00417         str += "FreeCAD exception thrown (";
00418         str += e.what();
00419         str += ")";
00420         e.ReportException();
00421         PyErr_SetString(PyExc_Exception,str.c_str());
00422         return -1;
00423     }
00424     catch(const Py::Exception&)
00425     {
00426         // The exception text is already set
00427         return -1;
00428     }
00429 #endif  // DONT_CATCH_CXX_EXCEPTIONS
00430 
00431     return GeometryCurvePy::_setattr(attr, value);
00432 }
00433 
00434 GeomArcOfCircle *ArcOfCirclePy::getGeomArcOfCirclePtr(void) const
00435 {
00436     return static_cast<GeomArcOfCircle *>(_pcTwinPointer);
00437 }
00438 
00439 #if 0
00440 /* From here on come the methods you have to implement, but NOT in this module. Implement in ArcOfCirclePyImp.cpp! This prototypes 
00441  * are just for convenience when you add a new method.
00442  */
00443 
00444 PyObject *ArcOfCirclePy::PyMake(struct _typeobject *, PyObject *, PyObject *)  // Python wrapper
00445 {
00446     // create a new instance of ArcOfCirclePy and the Twin object 
00447     return new ArcOfCirclePy(new GeomArcOfCircle);
00448 }
00449 
00450 // constructor method
00451 int ArcOfCirclePy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
00452 {
00453     return 0;
00454 }
00455 
00456 // returns a string which represents the object e.g. when printed in python
00457 std::string ArcOfCirclePy::representation(void) const
00458 {
00459     return std::string("<GeomArcOfCircle object>");
00460 }
00461 
00462 
00463 
00464 Py::Float ArcOfCirclePy::getRadius(void) const
00465 {
00466     //return Py::Float();
00467     throw Py::AttributeError("Not yet implemented");
00468 }
00469 
00470 void  ArcOfCirclePy::setRadius(Py::Float arg)
00471 {
00472     throw Py::AttributeError("Not yet implemented");
00473 }
00474 
00475 Py::Object ArcOfCirclePy::getCenter(void) const
00476 {
00477     //return Py::Object();
00478     throw Py::AttributeError("Not yet implemented");
00479 }
00480 
00481 void  ArcOfCirclePy::setCenter(Py::Object arg)
00482 {
00483     throw Py::AttributeError("Not yet implemented");
00484 }
00485 
00486 Py::Object ArcOfCirclePy::getAxis(void) const
00487 {
00488     //return Py::Object();
00489     throw Py::AttributeError("Not yet implemented");
00490 }
00491 
00492 void  ArcOfCirclePy::setAxis(Py::Object arg)
00493 {
00494     throw Py::AttributeError("Not yet implemented");
00495 }
00496 
00497 Py::Object ArcOfCirclePy::getCircle(void) const
00498 {
00499     //return Py::Object();
00500     throw Py::AttributeError("Not yet implemented");
00501 }
00502 
00503 PyObject *ArcOfCirclePy::getCustomAttributes(const char* attr) const
00504 {
00505     return 0;
00506 }
00507 
00508 int ArcOfCirclePy::setCustomAttributes(const char* attr, PyObject *obj)
00509 {
00510     return 0; 
00511 }
00512 #endif
00513 
00514 
00515 

Generated on Wed Nov 23 18:59:57 2011 for FreeCAD by  doxygen 1.6.1