/* -*- Mode: C; c-basic-offset: 4 -*- */

/* cplplotcanvas.override - C python wrapper override for plplotcanvas

  Copyright (C) 2004, 2005 Thomas J. Duck
  All rights reserved.

  Thomas J. Duck <tom.duck@dal.ca>
  Department of Physics and Atmospheric Science,
  Dalhousie University, Halifax, Nova Scotia, Canada, B3H 3J5


NOTICE

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library 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
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
  USA 
*/

/*-------------------------------------------------------------------------*/
/*                                                                         */
/* NOTES                                                                   */
/*                                                                         */
/* ignore-glob section:                                                    */
/*                                                                         */
/*   Methods in the plplot common library that can be wrapped have         */
/*   been removed from the list.                                           */
/*                                                                         */
/*   Plplot methods with constant arguments are wrapped automatically.     */
/*                                                                         */
/*   Commonly-used routines with non-constant arguments are wrapped using  */
/*   overrides, below, if required for speed.                              */
/*                                                                         */
/*   Routines that cannot be automatically wrapped are called from python  */
/*   code in plplotcanvas.Canvas using __getattr__.                        */
/*                                                                         */
/*-------------------------------------------------------------------------*/

%%
headers
#include <Python.h>        
       
#include "pygobject.h"
#include "plplot.h"
#include "plplotcanvas.h"

#define PY_ARRAY_UNIQUE_SYMBOL plplotcanvasapi
#include "arrayobject.h"
%%
%%modulename c_plplotcanvas
%%
import gnomecanvas.Canvas as PyGnomeCanvas_Type
%%
ignore-glob
  *_get_type
  plplot_canvas_arrows
  plplot_canvas_vect
  plplot_canvas_svect
  plplot_canvas_axes
  plplot_canvas_bin
  plplot_canvas_box
  plplot_canvas_box3
  plplot_canvas_calc_world
  plplot_canvas_cont
  plplot_canvas_fcont
  plplot_canvas_did2pc
  plplot_canvas_dip2dc
  plplot_canvas_errx
  plplot_canvas_erry
  plplot_canvas_fill
  plplot_canvas_fill3
  plplot_canvas_gchr
  plplot_canvas_gcol0
  plplot_canvas_gcolbg
  plplot_canvas_gcompression
  plplot_canvas_gdev
  plplot_canvas_gdidev
  plplot_canvas_gdiori
  plplot_canvas_gdiplt
  plplot_canvas_glevel
  plplot_canvas_gpage
  plplot_canvas_griddata
  plplot_canvas_gspa
  plplot_canvas_gver
  plplot_canvas_gvpd
  plplot_canvas_gvpw
  plplot_canvas_gxax
  plplot_canvas_gyax
  plplot_canvas_gzax
  plplot_canvas_hist
  plplot_canvas_lab
  plplot_canvas_line3
  plplot_canvas_map
  plplot_canvas_meridians
  plplot_canvas_mesh
  plplot_canvas_meshc
  plplot_canvas_plmtex
  plplot_canvas_plot3d
  plplot_canvas_plot3dc
  plplot_canvas_plot3dcl
  plplot_canvas_pat
  plplot_canvas_poin
  plplot_canvas_poin3
  plplot_canvas_poly3
  plplot_canvas_ptex
  plplot_canvas_scmap0
  plplot_canvas_gcmap0n
  plplot_canvas_scmap1
  plplot_canvas_scmap1l
  plplot_canvas_shade
  plplot_canvas_shade1
  plplot_canvas_shades
  plplot_canvas_fshade
  plplot_canvas_image
  plplot_canvas_styl
  plplot_canvas_surf3d
  plplot_canvas_surf3dl
  plplot_canvas_sym
  plplot_canvas_xormod
%%
override plplot_canvas_new args, kwargs
static int
_wrap_plplot_canvas_new(PyGObject *self, PyObject *args, PyObject *kwargs)
{
    GType obj_type = pyg_type_from_object((PyObject *) self);

    self->obj = g_object_new(obj_type, "aa", TRUE, NULL);
    if (!self->obj) {
        PyErr_SetString(PyExc_RuntimeError, "could not create %(typename)s object");
        return -1;
    }

    pygobject_register_wrapper((PyObject *)self);
    return 0;
}
%%
override plplot_canvas_line args
static PyObject* _wrap_plplot_canvas_line(PyGObject *self,
					  PyObject *args)
{
    PyObject *x_,*y_;
    PyArrayObject *x, *y;

    if(!PyArg_UnpackTuple(args,"ref",2,2,&x_,&y_))
	return NULL;

    if(!PyArray_Check(x_)) return NULL;
    if( (x = (PyArrayObject *)
	 PyArray_ContiguousFromObject(x_, PyArray_DOUBLE, 1, 1)) == NULL)
	return NULL;

    if(!PyArray_Check(y_)) return NULL;
    if( (y = (PyArrayObject *)
	 PyArray_ContiguousFromObject(y_, PyArray_DOUBLE, 1, 1)) == NULL)
	return NULL;

    plplot_canvas_line(PLPLOT_CANVAS(self->obj),
		       x->dimensions[0],(double*)x->data,(double*)y->data);

    return Py_BuildValue("");
}
