// Copyright (C) 2005 Gideon May (gideon@computer.org) // // Permission to copy, use, sell and distribute this software is granted // provided this copyright notice appears in all copies. // Permission to modify the code and to distribute modified code is granted // provided this copyright notice appears in all copies, and a notice // that the code was modified is included with the copyright notice. // // This software is provided "as is" without express or implied warranty, // and with no claim as to its suitability for any purpose. #include #include #include #include "held_ptr.hpp" using namespace boost::python; namespace { class ScalarsToColorsBase : public osgSim::ScalarsToColors { public: ScalarsToColorsBase(float scalarMin, float scalarMax) : osgSim::ScalarsToColors(scalarMin, scalarMax) {} }; class ScalarsToColorsBase_imp : public ScalarsToColorsBase { public: ScalarsToColorsBase_imp(PyObject * self, float scalarMin, float scalarMax) : ScalarsToColorsBase(scalarMin, scalarMax), _self(self) {} virtual ~ScalarsToColorsBase_imp() {} virtual osg::Vec4 getColor(float scalar) const { return call_method(_self, "getColor", scalar); } virtual osg::Vec4 getColor_imp(float scalar) const { return osgSim::ScalarsToColors::getColor(scalar); } private: PyObject * _self; }; } namespace PyOSGSim { void init_ScalarsToColors() { { class_, bases > scalars_to_colors("ScalarsToColors", no_init); scalars_to_colors .def(init()) ; } { class_, bases, boost::noncopyable > scalars_to_colors("ScalarsToColors_base", no_init); scalars_to_colors .def(init()) .def("getColor", &ScalarsToColorsBase_imp::getColor_imp) ; } } }