00001
00002
00003
00004
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 Robot;
00018
00020 PyTypeObject WaypointPy::Type = {
00021 PyObject_HEAD_INIT(&PyType_Type)
00022 0,
00023 "Robot.Waypoint",
00024 sizeof(WaypointPy),
00025 0,
00026
00027 PyDestructor,
00028 0,
00029 __getattr,
00030 __setattr,
00031 0,
00032 __repr,
00033 0,
00034 0,
00035 0,
00036 0,
00037 0,
00038 0,
00039 0,
00040 0,
00041
00042 0,
00043
00044 Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_CLASS,
00045 "Waypoint class",
00046 0,
00047 0,
00048 0,
00049 0,
00050 0,
00051 0,
00052 Robot::WaypointPy::Methods,
00053 0,
00054 Robot::WaypointPy::GetterSetter,
00055 &Base::PersistencePy::Type,
00056 0,
00057 0,
00058 0,
00059 0,
00060 __PyInit,
00061 0,
00062 Robot::WaypointPy::PyMake,
00063 0,
00064 0,
00065 0,
00066 0,
00067 0,
00068 0,
00069 0,
00070 0
00071 };
00072
00074 PyMethodDef WaypointPy::Methods[] = {
00075 {NULL, NULL, 0, NULL}
00076 };
00077
00078
00079
00081 PyGetSetDef WaypointPy::GetterSetter[] = {
00082 {"Name",
00083 (getter) staticCallback_getName,
00084 (setter) staticCallback_setName,
00085 "Name of the waypoint",
00086 NULL
00087 },
00088 {"Type",
00089 (getter) staticCallback_getType,
00090 (setter) staticCallback_setType,
00091 "Type of the waypoint[PTP|LIN|CIRC|WAIT]",
00092 NULL
00093 },
00094 {"Pos",
00095 (getter) staticCallback_getPos,
00096 (setter) staticCallback_setPos,
00097 "End position (destination) of the the waypoint",
00098 NULL
00099 },
00100 {"Cont",
00101 (getter) staticCallback_getCont,
00102 (setter) staticCallback_setCont,
00103 "Control the continuity to the next waypoint in the trajectory",
00104 NULL
00105 },
00106 {"Velocity",
00107 (getter) staticCallback_getVelocity,
00108 (setter) staticCallback_setVelocity,
00109 "Control the velocity to the next waypoint in the trajectory\nIn Case of PTP 0-100% Axis speed\nIn Case of LIN m/s\nIn Case of WAIT s wait time\n",
00110 NULL
00111 },
00112 {"Tool",
00113 (getter) staticCallback_getTool,
00114 (setter) staticCallback_setTool,
00115 "descripe which tool frame to use for that point",
00116 NULL
00117 },
00118 {"Base",
00119 (getter) staticCallback_getBase,
00120 (setter) staticCallback_setBase,
00121 "descripe which Base frame to use for that point",
00122 NULL
00123 },
00124 {NULL, NULL, NULL, NULL, NULL}
00125 };
00126
00127
00128
00129
00130 PyObject * WaypointPy::staticCallback_getName (PyObject *self, void * )
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 NULL;
00135 }
00136
00137 try {
00138 return Py::new_reference_to(((WaypointPy*)self)->getName());
00139 } catch (const Py::Exception&) {
00140
00141 return NULL;
00142 } catch (...) {
00143 PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Name' of object 'Waypoint'");
00144 return NULL;
00145 }
00146 }
00147
00148 int WaypointPy::staticCallback_setName (PyObject *self, PyObject *value, void * )
00149 {
00150 if (!((PyObjectBase*) self)->isValid()){
00151 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00152 return -1;
00153 }
00154 if (((PyObjectBase*) self)->isConst()){
00155 PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
00156 return -1;
00157 }
00158
00159 try {
00160 ((WaypointPy*)self)->setName(Py::String(value,false));
00161 return 0;
00162 } catch (const Py::Exception&) {
00163
00164 return -1;
00165 } catch (...) {
00166 PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'Name' of object 'Waypoint'");
00167 return -1;
00168 }
00169 }
00170
00171
00172
00173
00174 PyObject * WaypointPy::staticCallback_getType (PyObject *self, void * )
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 NULL;
00179 }
00180
00181 try {
00182 return Py::new_reference_to(((WaypointPy*)self)->getType());
00183 } catch (const Py::Exception&) {
00184
00185 return NULL;
00186 } catch (...) {
00187 PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Type' of object 'Waypoint'");
00188 return NULL;
00189 }
00190 }
00191
00192 int WaypointPy::staticCallback_setType (PyObject *self, PyObject *value, void * )
00193 {
00194 if (!((PyObjectBase*) self)->isValid()){
00195 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00196 return -1;
00197 }
00198 if (((PyObjectBase*) self)->isConst()){
00199 PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
00200 return -1;
00201 }
00202
00203 try {
00204 ((WaypointPy*)self)->setType(Py::String(value,false));
00205 return 0;
00206 } catch (const Py::Exception&) {
00207
00208 return -1;
00209 } catch (...) {
00210 PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'Type' of object 'Waypoint'");
00211 return -1;
00212 }
00213 }
00214
00215
00216
00217
00218 PyObject * WaypointPy::staticCallback_getPos (PyObject *self, void * )
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 NULL;
00223 }
00224
00225 try {
00226 return Py::new_reference_to(((WaypointPy*)self)->getPos());
00227 } catch (const Py::Exception&) {
00228
00229 return NULL;
00230 } catch (...) {
00231 PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Pos' of object 'Waypoint'");
00232 return NULL;
00233 }
00234 }
00235
00236 int WaypointPy::staticCallback_setPos (PyObject *self, PyObject *value, void * )
00237 {
00238 if (!((PyObjectBase*) self)->isValid()){
00239 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00240 return -1;
00241 }
00242 if (((PyObjectBase*) self)->isConst()){
00243 PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
00244 return -1;
00245 }
00246
00247 try {
00248 ((WaypointPy*)self)->setPos(Py::Object(value,false));
00249 return 0;
00250 } catch (const Py::Exception&) {
00251
00252 return -1;
00253 } catch (...) {
00254 PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'Pos' of object 'Waypoint'");
00255 return -1;
00256 }
00257 }
00258
00259
00260
00261
00262 PyObject * WaypointPy::staticCallback_getCont (PyObject *self, void * )
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 NULL;
00267 }
00268
00269 try {
00270 return Py::new_reference_to(((WaypointPy*)self)->getCont());
00271 } catch (const Py::Exception&) {
00272
00273 return NULL;
00274 } catch (...) {
00275 PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Cont' of object 'Waypoint'");
00276 return NULL;
00277 }
00278 }
00279
00280 int WaypointPy::staticCallback_setCont (PyObject *self, PyObject *value, void * )
00281 {
00282 if (!((PyObjectBase*) self)->isValid()){
00283 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00284 return -1;
00285 }
00286 if (((PyObjectBase*) self)->isConst()){
00287 PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
00288 return -1;
00289 }
00290
00291 try {
00292 ((WaypointPy*)self)->setCont(Py::Boolean(value,false));
00293 return 0;
00294 } catch (const Py::Exception&) {
00295
00296 return -1;
00297 } catch (...) {
00298 PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'Cont' of object 'Waypoint'");
00299 return -1;
00300 }
00301 }
00302
00303
00304
00305
00306 PyObject * WaypointPy::staticCallback_getVelocity (PyObject *self, void * )
00307 {
00308 if (!((PyObjectBase*) self)->isValid()){
00309 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00310 return NULL;
00311 }
00312
00313 try {
00314 return Py::new_reference_to(((WaypointPy*)self)->getVelocity());
00315 } catch (const Py::Exception&) {
00316
00317 return NULL;
00318 } catch (...) {
00319 PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Velocity' of object 'Waypoint'");
00320 return NULL;
00321 }
00322 }
00323
00324 int WaypointPy::staticCallback_setVelocity (PyObject *self, PyObject *value, void * )
00325 {
00326 if (!((PyObjectBase*) self)->isValid()){
00327 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00328 return -1;
00329 }
00330 if (((PyObjectBase*) self)->isConst()){
00331 PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
00332 return -1;
00333 }
00334
00335 try {
00336 ((WaypointPy*)self)->setVelocity(Py::Float(value,false));
00337 return 0;
00338 } catch (const Py::Exception&) {
00339
00340 return -1;
00341 } catch (...) {
00342 PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'Velocity' of object 'Waypoint'");
00343 return -1;
00344 }
00345 }
00346
00347
00348
00349
00350 PyObject * WaypointPy::staticCallback_getTool (PyObject *self, void * )
00351 {
00352 if (!((PyObjectBase*) self)->isValid()){
00353 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00354 return NULL;
00355 }
00356
00357 try {
00358 return Py::new_reference_to(((WaypointPy*)self)->getTool());
00359 } catch (const Py::Exception&) {
00360
00361 return NULL;
00362 } catch (...) {
00363 PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Tool' of object 'Waypoint'");
00364 return NULL;
00365 }
00366 }
00367
00368 int WaypointPy::staticCallback_setTool (PyObject *self, PyObject *value, void * )
00369 {
00370 if (!((PyObjectBase*) self)->isValid()){
00371 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00372 return -1;
00373 }
00374 if (((PyObjectBase*) self)->isConst()){
00375 PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
00376 return -1;
00377 }
00378
00379 try {
00380 ((WaypointPy*)self)->setTool(Py::Int(value,false));
00381 return 0;
00382 } catch (const Py::Exception&) {
00383
00384 return -1;
00385 } catch (...) {
00386 PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'Tool' of object 'Waypoint'");
00387 return -1;
00388 }
00389 }
00390
00391
00392
00393
00394 PyObject * WaypointPy::staticCallback_getBase (PyObject *self, void * )
00395 {
00396 if (!((PyObjectBase*) self)->isValid()){
00397 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00398 return NULL;
00399 }
00400
00401 try {
00402 return Py::new_reference_to(((WaypointPy*)self)->getBase());
00403 } catch (const Py::Exception&) {
00404
00405 return NULL;
00406 } catch (...) {
00407 PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Base' of object 'Waypoint'");
00408 return NULL;
00409 }
00410 }
00411
00412 int WaypointPy::staticCallback_setBase (PyObject *self, PyObject *value, void * )
00413 {
00414 if (!((PyObjectBase*) self)->isValid()){
00415 PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00416 return -1;
00417 }
00418 if (((PyObjectBase*) self)->isConst()){
00419 PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
00420 return -1;
00421 }
00422
00423 try {
00424 ((WaypointPy*)self)->setBase(Py::Int(value,false));
00425 return 0;
00426 } catch (const Py::Exception&) {
00427
00428 return -1;
00429 } catch (...) {
00430 PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'Base' of object 'Waypoint'");
00431 return -1;
00432 }
00433 }
00434
00435
00436
00437
00438
00439
00440 PyParentObject WaypointPy::Parents[] = { PARENTSRobotWaypointPy };
00441
00442
00443
00444
00445 WaypointPy::WaypointPy(Waypoint *pcObject, PyTypeObject *T)
00446 : PersistencePy(reinterpret_cast<PersistencePy::PointerType>(pcObject), T)
00447 {
00448 }
00449
00450
00451
00452
00453
00454 WaypointPy::~WaypointPy()
00455 {
00456
00457 WaypointPy::PointerType ptr = reinterpret_cast<WaypointPy::PointerType>(_pcTwinPointer);
00458 delete ptr;
00459 }
00460
00461
00462
00463
00464 PyObject *WaypointPy::_repr(void)
00465 {
00466 return Py_BuildValue("s", representation().c_str());
00467 }
00468
00469
00470
00471
00472 PyObject *WaypointPy::_getattr(char *attr)
00473 {
00474 try {
00475
00476 PyObject *r = getCustomAttributes(attr);
00477 if(r) return r;
00478 }
00479 #ifndef DONT_CATCH_CXX_EXCEPTIONS
00480 catch(const Base::Exception& e)
00481 {
00482 std::string str;
00483 str += "FreeCAD exception thrown (";
00484 str += e.what();
00485 str += ")";
00486 e.ReportException();
00487 PyErr_SetString(PyExc_Exception,str.c_str());
00488 return NULL;
00489 }
00490 catch(const std::exception& e)
00491 {
00492 std::string str;
00493 str += "FC++ exception thrown (";
00494 str += e.what();
00495 str += ")";
00496 Base::Console().Error(str.c_str());
00497 PyErr_SetString(PyExc_Exception,str.c_str());
00498 return NULL;
00499 }
00500 catch(const Py::Exception&)
00501 {
00502
00503 return NULL;
00504 }
00505 catch(...)
00506 {
00507 PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00508 return NULL;
00509 }
00510 #else // DONT_CATCH_CXX_EXCEPTIONS
00511 catch(const Base::Exception& e)
00512 {
00513 std::string str;
00514 str += "FreeCAD exception thrown (";
00515 str += e.what();
00516 str += ")";
00517 e.ReportException();
00518 PyErr_SetString(PyExc_Exception,str.c_str());
00519 return NULL;
00520 }
00521 catch(const Py::Exception&)
00522 {
00523
00524 return NULL;
00525 }
00526 #endif // DONT_CATCH_CXX_EXCEPTIONS
00527
00528 PyObject *rvalue = Py_FindMethod(Methods, this, attr);
00529 if (rvalue == NULL)
00530 {
00531 PyErr_Clear();
00532 return PersistencePy::_getattr(attr);
00533 }
00534 else
00535 {
00536 return rvalue;
00537 }
00538 }
00539
00540 int WaypointPy::_setattr(char *attr, PyObject *value)
00541 {
00542 try {
00543
00544 int r = setCustomAttributes(attr, value);
00545 if(r==1) return 0;
00546 }
00547 #ifndef DONT_CATCH_CXX_EXCEPTIONS
00548 catch(const Base::Exception& e)
00549 {
00550 std::string str;
00551 str += "FreeCAD exception thrown (";
00552 str += e.what();
00553 str += ")";
00554 e.ReportException();
00555 PyErr_SetString(PyExc_Exception,str.c_str());
00556 return -1;
00557 }
00558 catch(const std::exception& e)
00559 {
00560 std::string str;
00561 str += "FC++ exception thrown (";
00562 str += e.what();
00563 str += ")";
00564 Base::Console().Error(str.c_str());
00565 PyErr_SetString(PyExc_Exception,str.c_str());
00566 return -1;
00567 }
00568 catch(const Py::Exception&)
00569 {
00570
00571 return -1;
00572 }
00573 catch(...)
00574 {
00575 PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00576 return -1;
00577 }
00578 #else // DONT_CATCH_CXX_EXCEPTIONS
00579 catch(const Base::Exception& e)
00580 {
00581 std::string str;
00582 str += "FreeCAD exception thrown (";
00583 str += e.what();
00584 str += ")";
00585 e.ReportException();
00586 PyErr_SetString(PyExc_Exception,str.c_str());
00587 return -1;
00588 }
00589 catch(const Py::Exception&)
00590 {
00591
00592 return -1;
00593 }
00594 #endif // DONT_CATCH_CXX_EXCEPTIONS
00595
00596 return PersistencePy::_setattr(attr, value);
00597 }
00598
00599 Waypoint *WaypointPy::getWaypointPtr(void) const
00600 {
00601 return static_cast<Waypoint *>(_pcTwinPointer);
00602 }
00603
00604 #if 0
00605
00606
00607
00608
00609 PyObject *WaypointPy::PyMake(struct _typeobject *, PyObject *, PyObject *)
00610 {
00611
00612 return new WaypointPy(new Waypoint);
00613 }
00614
00615
00616 int WaypointPy::PyInit(PyObject* , PyObject* )
00617 {
00618 return 0;
00619 }
00620
00621
00622 std::string WaypointPy::representation(void) const
00623 {
00624 return std::string("<Waypoint object>");
00625 }
00626
00627
00628
00629 Py::String WaypointPy::getName(void) const
00630 {
00631
00632 throw Py::AttributeError("Not yet implemented");
00633 }
00634
00635 void WaypointPy::setName(Py::String arg)
00636 {
00637 throw Py::AttributeError("Not yet implemented");
00638 }
00639
00640 Py::String WaypointPy::getType(void) const
00641 {
00642
00643 throw Py::AttributeError("Not yet implemented");
00644 }
00645
00646 void WaypointPy::setType(Py::String arg)
00647 {
00648 throw Py::AttributeError("Not yet implemented");
00649 }
00650
00651 Py::Object WaypointPy::getPos(void) const
00652 {
00653
00654 throw Py::AttributeError("Not yet implemented");
00655 }
00656
00657 void WaypointPy::setPos(Py::Object arg)
00658 {
00659 throw Py::AttributeError("Not yet implemented");
00660 }
00661
00662 Py::Boolean WaypointPy::getCont(void) const
00663 {
00664
00665 throw Py::AttributeError("Not yet implemented");
00666 }
00667
00668 void WaypointPy::setCont(Py::Boolean arg)
00669 {
00670 throw Py::AttributeError("Not yet implemented");
00671 }
00672
00673 Py::Float WaypointPy::getVelocity(void) const
00674 {
00675
00676 throw Py::AttributeError("Not yet implemented");
00677 }
00678
00679 void WaypointPy::setVelocity(Py::Float arg)
00680 {
00681 throw Py::AttributeError("Not yet implemented");
00682 }
00683
00684 Py::Int WaypointPy::getTool(void) const
00685 {
00686
00687 throw Py::AttributeError("Not yet implemented");
00688 }
00689
00690 void WaypointPy::setTool(Py::Int arg)
00691 {
00692 throw Py::AttributeError("Not yet implemented");
00693 }
00694
00695 Py::Int WaypointPy::getBase(void) const
00696 {
00697
00698 throw Py::AttributeError("Not yet implemented");
00699 }
00700
00701 void WaypointPy::setBase(Py::Int arg)
00702 {
00703 throw Py::AttributeError("Not yet implemented");
00704 }
00705
00706 PyObject *WaypointPy::getCustomAttributes(const char* attr) const
00707 {
00708 return 0;
00709 }
00710
00711 int WaypointPy::setCustomAttributes(const char* attr, PyObject *obj)
00712 {
00713 return 0;
00714 }
00715 #endif
00716
00717
00718