#include "VTransferFunctionNode.h"
#include "V2Ddraw.h"
#include <math.h>
#include <iostream>

VTransferFunctionNode::VTransferFunctionNode(int x, int y) {
	this->x = x;
	this->y = y;
	this->color = new float[3];
	this->color[0] = this->color[1] = this->color[2] = 1.0;
	this->opacity = 0.0;
	this->choose = true;
}

void VTransferFunctionNode::draw() {
	V2Ddraw::drawCircle(x,y,5);
}

float * VTransferFunctionNode::getColor() {
	return this->color;
}

int VTransferFunctionNode::getx() {
	return this->x;
}

int VTransferFunctionNode::gety() {
	return this->y;
}

void VTransferFunctionNode::setx(int x) {
	this->x = x;
}

void VTransferFunctionNode::sety(int y) {
	this->y = y;
}

bool VTransferFunctionNode::isInside(int xm, int ym) {
	return sqrt(pow((double)ym-this->y,2)+pow((double)xm-this->x,2)) < 5;
}

bool VTransferFunctionNode::isChoosed() {
	return this->choose;
}

void VTransferFunctionNode::setChoosed(bool choose) {
	this->choose = choose;
}

/*bool VTransferFunctionNode::operator< (const VTransferFunctionNode& op) {
	return this->x < op.x;
}

bool VTransferFunctionNode::operator== (VTransferFunctionNode op) {
	//cout << this->x << " " << op.x << " " << this->y << " " << op.y << endl;
	return this->x == op.x && this->y == op.y;
}

bool VTransferFunctionNode::operator!= (VTransferFunctionNode op) {
	//cout << this->x << " " << op.x << " " << this->y << " " << op.y << endl;
	return this->x != op.x && this->y != op.y;
}*/

float VTransferFunctionNode::getOpacity(int height, int y) {
	return ((float)this->y - y) /(float)height;
}

VTransferFunctionNode::~VTransferFunctionNode(void)
{
	//delete[] this->color;
}
