00001 #include "VTransferFunctionNode.h" 00002 #include "V2Ddraw.h" 00003 #include <math.h> 00004 #include <iostream> 00005 00006 VTransferFunctionNode::VTransferFunctionNode(int x, int y) { 00007 this->x = x; 00008 this->y = y; 00009 this->color = new float[3]; 00010 this->color[0] = this->color[1] = this->color[2] = 1.0; 00011 this->opacity = 0.0; 00012 this->choose = true; 00013 } 00014 00015 void VTransferFunctionNode::draw() { 00016 V2Ddraw::drawCircle(x,y,5); 00017 } 00018 00019 float * VTransferFunctionNode::getColor() { 00020 return this->color; 00021 } 00022 00023 int VTransferFunctionNode::getx() { 00024 return this->x; 00025 } 00026 00027 int VTransferFunctionNode::gety() { 00028 return this->y; 00029 } 00030 00031 void VTransferFunctionNode::setx(int x) { 00032 this->x = x; 00033 } 00034 00035 void VTransferFunctionNode::sety(int y) { 00036 this->y = y; 00037 } 00038 00039 bool VTransferFunctionNode::isInside(int xm, int ym) { 00040 return sqrt(pow((double)ym-this->y,2)+pow((double)xm-this->x,2)) < 5; 00041 } 00042 00043 bool VTransferFunctionNode::isChoosed() { 00044 return this->choose; 00045 } 00046 00047 void VTransferFunctionNode::setChoosed(bool choose) { 00048 this->choose = choose; 00049 } 00050 00051 /*bool VTransferFunctionNode::operator< (const VTransferFunctionNode& op) { 00052 return this->x < op.x; 00053 } 00054 00055 bool VTransferFunctionNode::operator== (VTransferFunctionNode op) { 00056 //cout << this->x << " " << op.x << " " << this->y << " " << op.y << endl; 00057 return this->x == op.x && this->y == op.y; 00058 } 00059 00060 bool VTransferFunctionNode::operator!= (VTransferFunctionNode op) { 00061 //cout << this->x << " " << op.x << " " << this->y << " " << op.y << endl; 00062 return this->x != op.x && this->y != op.y; 00063 }*/ 00064 00065 float VTransferFunctionNode::getOpacity(int height) { 00066 return (float)this->y/(float)height; 00067 } 00068 00069 VTransferFunctionNode::~VTransferFunctionNode(void) 00070 { 00071 //delete[] this->color; 00072 }