From: <sv...@ww...> - 2005-02-05 04:08:58
|
Author: mkrose Date: 2005-02-04 20:08:48 -0800 (Fri, 04 Feb 2005) New Revision: 1459 Added: trunk/CSP/CSPSim/Tools/Layout/cLayout.i trunk/CSP/CSPSim/Tools/Layout/cLoader.i Log: Oops, forgot the swig files. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=1459 Added: trunk/CSP/CSPSim/Tools/Layout/cLayout.i =================================================================== --- trunk/CSP/CSPSim/Tools/Layout/cLayout.i 2005-01-31 01:25:00 UTC (rev 1458) +++ trunk/CSP/CSPSim/Tools/Layout/cLayout.i 2005-02-05 04:08:48 UTC (rev 1459) @@ -0,0 +1,97 @@ +// CSP Layout - Copyright 2003-2005 Mark Rose <mk...@us...> +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US + +%module(directors="1") cLayout +%{ +#include "View.h" +#include "LayoutNodes.h" +#include "FeatureGraph.h" +#include "InsertDeleteCommand.h" +%} + +%include "typemaps.i" +%include "std_string.i" +%include "std_vector.i" +%include "std_list.i" + +%template(vector_LayoutNodePtr) std::vector<LayoutNode*>; +%template(list_LayoutNodePtr) std::list<LayoutNode*>; + +%feature("director") ViewCallback; +%feature("director") GraphCallback; +%feature("director") LayoutNodeVisitor; + +%typemap(python, in) (int argc, char **argv) +{ + /* Check if is a list */ + if (PyList_Check($input)) + { + int i; + $1 = PyList_Size($input); + $2 = (char **) malloc(($1+1)*sizeof(char *)); + for (i = 0; i < $1; i++) + { + PyObject *o = PyList_GetItem($input,i); + if (PyString_Check(o)) + { + $2[i] = PyString_AsString(PyList_GetItem($input,i)); + } + else + { + PyErr_SetString(PyExc_TypeError,"list must contain strings"); + free($2); + return NULL; + } + } + $2[i] = 0; + } + else + { + PyErr_SetString(PyExc_TypeError,"not a list"); + return NULL; + } +} + +%typemap(python, out) (osg::Vec3) +{ + PyObject* target = PyTuple_New(3); + PyTuple_SetItem(target, 0, PyFloat_FromDouble($1.x())); + PyTuple_SetItem(target, 1, PyFloat_FromDouble($1.y())); + PyTuple_SetItem(target, 2, PyFloat_FromDouble($1.z())); + $result = target; +} + +namespace osg { +class Referenced { +protected: + ~Referenced() { } +}; +} + +// Suppress director warning: +// FeatureGraph.h:30: Warning(515): +// Target language argument 'osg::Matrix const &to_world' discards const +// in director method GraphCallback::onActivate. +// Basically, just be careful not to modify to_world when subclassing +// GraphCallback in Python. +%warnfilter(515); + +%include "LayoutNodes.h" +%include "FeatureGraph.h" +%include "Undo.h" +%include "InsertDeleteCommand.h" +%include "View.h" + Added: trunk/CSP/CSPSim/Tools/Layout/cLoader.i =================================================================== --- trunk/CSP/CSPSim/Tools/Layout/cLoader.i 2005-01-31 01:25:00 UTC (rev 1458) +++ trunk/CSP/CSPSim/Tools/Layout/cLoader.i 2005-02-05 04:08:48 UTC (rev 1459) @@ -0,0 +1,27 @@ +// CSP Layout - Copyright 2003-2005 Mark Rose <mk...@us...> +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US + +%module cLoader +%{ +#include "Loader.h" +#include <osg/Node> +%} + +%include "typemaps.i" +%include "std_string.i" + +%include "Loader.h" + |