////////////////////////////////////////////////////////
//
// GEM - Graphics Environment for Multimedia
//
// geiger@py.co.at
//
// Implementation file
//
//    Copyright (c) 2000 Guenter Geiger
//    For information on usage and redistribution, and for a DISCLAIMER OF ALL
//    WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.
//
/////////////////////////////////////////////////////////

#include "mgck_base.h"


/////////////////////////////////////////////////////////
//
// mgck_base
//
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////

mgck_base :: mgck_base(int num)
{
  int i;
  char syms[20];

  for (i=1;i<=num;i++) {
    sprintf(syms,"ft%d",i);
    inlet_new(this->x_obj, &this->x_obj->ob_pd, gensym("float"), gensym(syms));
    m_arg[i-1] = 0.0;
  }
  GetExceptionInfo(&m_exception); 
}

/////////////////////////////////////////////////////////
// Destructor
//
/////////////////////////////////////////////////////////

mgck_base :: ~mgck_base()
{ }
 
/////////////////////////////////////////////////////////
// processImage
//
/////////////////////////////////////////////////////////

void mgck_base :: processImage(imageStruct &image)
{
    Image* newim;

    mgck_image = ConstituteImage (image.xsize, image.ysize, "RGBA",CharPixel, 
		     image.data, &m_exception ); 

    newim =  mgckProcess(image,m_arg);

    DispatchImage ( newim, 0, 0,image.xsize , image.ysize, "RGBA",CharPixel, image.data); 
    DestroyImage(mgck_image);
    DestroyImage(newim);
}


Image* mgck_base :: mgckProcess(imageStruct &image,t_float* a1)
{
	return NULL;
}



void mgck_base :: a1Mess(float r)
{
    // assumption that the alpha should be one
    m_arg[0] = r;
    setPixModified();
}

void mgck_base :: a1MessCallback(void *data, t_floatarg gain)
{
    GetMyClass(data)->a1Mess((float)gain);
}


void mgck_base :: a2Mess(float r)
{
    // assumption that the alpha should be one
    m_arg[1] = r;
    setPixModified();
}

void mgck_base :: a2MessCallback(void *data, t_floatarg gain)
{
    GetMyClass(data)->a2Mess((float)gain);
}


void mgck_base :: a3Mess(float r)
{
    // assumption that the alpha should be one
    m_arg[2] = r;
    setPixModified();
}

void mgck_base :: a3MessCallback(void *data, t_floatarg gain)
{
    GetMyClass(data)->a3Mess((float)gain);
}

void mgck_base :: a4Mess(float r)
{
    // assumption that the alpha should be one
    m_arg[3] = r;
    setPixModified();
}

void mgck_base :: a4MessCallback(void *data, t_floatarg gain)
{
    GetMyClass(data)->a4Mess((float)gain);
}


/////////////////////////////////////////////////////////
// static member function
//
/////////////////////////////////////////////////////////

void mgck_base :: obj_setupCallback(t_class * classPtr)
{
}


void mgck_base :: mobj_setupCallback(t_class * classPtr, int num)
{ 
  char syms[20];
  
  if (num >= 1) 
    class_addmethod(classPtr, (t_method)&mgck_base ::a1MessCallback,
    	    gensym("ft1"), A_FLOAT, A_NULL);
  if (num >= 2) 
    class_addmethod(classPtr, (t_method)&mgck_base ::a2MessCallback,
    	    gensym("ft2"), A_FLOAT, A_NULL);
  if (num >= 3) 
    class_addmethod(classPtr, (t_method)&mgck_base ::a3MessCallback,
    	    gensym("ft3"), A_FLOAT, A_NULL);
  if (num >= 4) 
    class_addmethod(classPtr, (t_method)&mgck_base ::a4MessCallback,
    	    gensym("ft4"), A_FLOAT, A_NULL);
  
}





