/*
* This file is part of robotreality
*
* Copyright(c) sschulz <AT> techfak.uni-bielefeld.de
* http://opensource.cit-ec.de/projects/robotreality
*
* This file may be licensed under the terms of the
* GNU General Public License Version 3 (the ``GPL''),
* or (at your option) any later version.
*
* Software distributed under the License is distributed
* on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
* express or implied. See the GPL for the specific language
* governing rights and limitations.
*
* You should have received a copy of the GPL along with this
* program. If not, go to http://www.gnu.org/licenses/gpl.html
* or write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The development of this software was supported by the
* Excellence Cluster EXC 277 Cognitive Interaction Technology.
* The Excellence Cluster EXC 277 is a grant of the Deutsche
* Forschungsgemeinschaft (DFG) in the context of the German
* Excellence Initiative.
*
*/

#include "GlobalHelpers.h"

void mouse_wrapper(int event, int x, int y, int flags, void* ptr){
    DotTracker* dot_ptr = (DotTracker*)ptr;
    if(dot_ptr != NULL)
        dot_ptr->handle_mouse_event(event, x, y, flags);
}


//global helper
void button_wrapper_bool(int state, void *data){
// 	printf("BUT click\n");
	if (data != NULL){
// 		printf("BUT not null \n");
		if (state){
			*((bool*)data) = true;
		}else{
			*((bool*)data) = false;
			destroyWindow("EYE LEFT");
			destroyWindow("EYE RIGHT");
		}
	}
};


void button_wrapper_output(int state, void *data){
	if(data!= NULL){
		DotTracker* dot_ptr = (DotTracker*)data;
		dot_ptr->set_output(state);
	}
}

//global helper
void button_refit_model(int state, void *data){
	if (data != NULL){
		DotTracker* dot_ptr = (DotTracker*)data;
		dot_ptr->refit_model();
	}
};

//global helper
void button_eye_zero(int state, void *data){
	if (data != NULL){
		DotTracker* dot_ptr = (DotTracker*)data;
		dot_ptr->set_eye_zero();
	}
};

//global helper
void button_calc_head_zero_rot(int state, void *data){
	if (data != NULL){
		DotTracker* dot_ptr = (DotTracker*)data;
		dot_ptr->calc_head_zero_rot();
	}
};

//global helper
void button_reset_framecounter(int state, void *data){
	if (data != NULL){
		DotTracker* dot_ptr = (DotTracker*)data;
		dot_ptr->reset_framecounter();
	}
};

void trackbar_set_eyefinder_brightness(int val, void *data){
	if (data != NULL){
		DotTracker* dot_ptr = (DotTracker*)data;
		dot_ptr->set_eyefinder_brightness_threshold(val);
	}
}


void trackbar_set_double_1000(int val, void *data){
	if (data != NULL){
		double *d = (double*)data;
		*d = ((double)val)/1000.0;
	}
}

void trackbar_set_double_100(int val, void *data){
	if (data != NULL){
		double *d = (double*)data;
		*d = ((double)val)/100.0;
	}
}

void trackbar_set_double_10(int val, void *data){
	if (data != NULL){
		double *d = (double*)data;
		*d = ((double)val)/10.0;
	}
}