//-----------------------------------------------------
void TransferFunctionView::Process()
{
- if(bbGetInputIn()!=NULL){
- mwxwidget->initializeHistogram(bbGetInputIn());
- mwxwidget->Refresh();
- }
-
+
+ std::vector<double> greylevel;
+ std::vector<double> value;
+
+ std::vector<double> greylevelcolors;
+ std::vector<double> red;
+ std::vector<double> green;
+ std::vector<double> blue;
+
+ if(bbGetInputIn()!=NULL){
+
+ if(_currentimg != bbGetInputIn()){
+ _currentimg = bbGetInputIn();
+ mwxwidget->initializeHistogram(_currentimg);
+ mwxwidget->Refresh();
+ }
+
+ mwxwidget->GetValuesPointsFunction(greylevel, value);
+ mwxwidget->GetValuesColorPointsFunction(greylevelcolors,red, green,blue);
+
+
+ _tfun->RemoveAllPoints();
+ for(int i = 0; i < greylevel.size();i++){
+ _tfun->AddPoint(greylevel[i], value[i]);
+// std::cout<<"transfer function "<<greylevel[i]<<" "<< value[i]<<std::endl;
+ }
+ _ctfun->RemoveAllPoints();
+ for(int i = 0; i < greylevelcolors.size();i++){
+ _ctfun->AddRGBPoint(greylevelcolors[i], red[i],green[i], blue[i]);
+// std::cout<<"transfer color function "<<greylevelcolors[i]<<" "<<red[i]<<" "<<green[i]<<" "<<blue[i]<<std::endl;
+ }
+
+
+ bbSetOutputOpacityFunction(_tfun);
+ bbSetOutputColorFunction(_ctfun);
+ /*bbSetOutputGreyLevel(greylevel);
+ bbSetOutputValue(value);
+ bbSetOutputGreyLevelColors(greylevelcolors);
+ bbSetOutputRed(red);
+ bbSetOutputGreen(green);
+ bbSetOutputBlue(blue);*/
+
+
+
+
+ }
+
+
}
//-----------------------------------------------------
void TransferFunctionView::bbUserSetDefaultValues()
{
mwxwidget = NULL;
+ _currentimg = NULL;
+
+ _tfun = NULL;
+ _ctfun = NULL;
}
//-----------------------------------------------------------------
void TransferFunctionView::bbUserInitializeProcessing()
{
+ _tfun = vtkPiecewiseFunction::New();
+ _ctfun = vtkColorTransferFunction::New();
bbSetInputIn(NULL);
}