PropertyTrajectory.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) Jürgen Riegel          (juergen.riegel@web.de) 2002     *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
00020  *                                                                         *
00021  ***************************************************************************/
00022 
00023 
00024 #include "PreCompiled.h"
00025 
00026 #ifndef _PreComp_
00027 # include <sstream>
00028 #endif
00029 
00030 
00031 #include <strstream>
00032 #include <Base/Console.h>
00033 #include <Base/Writer.h>
00034 #include <Base/Reader.h>
00035 #include <Base/Exception.h>
00036 #include <Base/FileInfo.h>
00037 #include <Base/Stream.h>
00038 
00039 #include "PropertyTrajectory.h"
00040 #include "TrajectoryPy.h"
00041 
00042 using namespace Robot;
00043 
00044 TYPESYSTEM_SOURCE(Robot::PropertyTrajectory , App::Property);
00045 
00046 PropertyTrajectory::PropertyTrajectory()
00047 {
00048 }
00049 
00050 PropertyTrajectory::~PropertyTrajectory()
00051 {
00052 }
00053 
00054 void PropertyTrajectory::setValue(const Trajectory& sh)
00055 {
00056     aboutToSetValue();
00057     _Trajectory = sh;
00058     hasSetValue();
00059 }
00060 
00061 
00062 const Trajectory &PropertyTrajectory::getValue(void)const 
00063 {
00064     return _Trajectory;
00065 }
00066 
00067 
00068 Base::BoundBox3d PropertyTrajectory::getBoundingBox() const
00069 {
00070     Base::BoundBox3d box;
00071     //if (_Trajectory._Trajectory.IsNull())
00072     //    return box;
00073     //try {
00074     //    // If the shape is empty an exception may be thrown
00075     //    Bnd_Box bounds;
00076     //    BRepBndLib::Add(_Trajectory._Trajectory, bounds);
00077     //    bounds.SetGap(0.0);
00078     //    Standard_Real xMin, yMin, zMin, xMax, yMax, zMax;
00079     //    bounds.Get(xMin, yMin, zMin, xMax, yMax, zMax);
00080 
00081     //    box.MinX = xMin;
00082     //    box.MaxX = xMax;
00083     //    box.MinY = yMin;
00084     //    box.MaxY = yMax;
00085     //    box.MinZ = zMin;
00086     //    box.MaxZ = zMax;
00087     //}
00088     //catch (Standard_Failure) {
00089     //}
00090 
00091     return box;
00092 }
00093 
00094 
00095 PyObject *PropertyTrajectory::getPyObject(void)
00096 {
00097     return new TrajectoryPy(new Trajectory(_Trajectory));
00098 }
00099 
00100 void PropertyTrajectory::setPyObject(PyObject *value)
00101 {
00102     if (PyObject_TypeCheck(value, &(TrajectoryPy::Type))) {
00103         TrajectoryPy *pcObject = static_cast<TrajectoryPy*>(value);
00104         setValue(*pcObject->getTrajectoryPtr());
00105     }
00106     else {
00107         std::string error = std::string("type must be 'Trajectory', not ");
00108         error += value->ob_type->tp_name;
00109         throw Py::TypeError(error);
00110     }
00111 }
00112 
00113 App::Property *PropertyTrajectory::Copy(void) const
00114 {
00115     PropertyTrajectory *prop = new PropertyTrajectory();
00116     prop->_Trajectory = this->_Trajectory;
00117  
00118     return prop;
00119 }
00120 
00121 void PropertyTrajectory::Paste(const App::Property &from)
00122 {
00123     aboutToSetValue();
00124     _Trajectory = dynamic_cast<const PropertyTrajectory&>(from)._Trajectory;
00125     hasSetValue();
00126 }
00127 
00128 unsigned int PropertyTrajectory::getMemSize (void) const
00129 {
00130     return _Trajectory.getMemSize();
00131 }
00132 
00133 void PropertyTrajectory::Save (Base::Writer &writer) const
00134 {
00135     _Trajectory.Save(writer);
00136 }
00137 
00138 void PropertyTrajectory::Restore(Base::XMLReader &reader)
00139 {
00140     Robot::Trajectory temp;
00141     temp.Restore(reader);
00142     setValue(temp);
00143 }
00144 
00145 
00146 

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