]> Creatis software - creaMaracasVisu.git/blobdiff - bbtk/src/bbmaracasvisuTransferFunctionView.cxx
*** empty log message ***
[creaMaracasVisu.git] / bbtk / src / bbmaracasvisuTransferFunctionView.cxx
index f95262df8dfc5aeea3d6a8e3df77254a50ae65ca..137f82b6b61a2eeb815732bfeded97b975773fda 100644 (file)
@@ -9,13 +9,56 @@ BBTK_BLACK_BOX_IMPLEMENTATION(TransferFunctionView,bbtk::WxBlackBox);
 //-----------------------------------------------------
 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);*/
+
+
+
+
+       }
+               
+    
 }
 
 //-----------------------------------------------------
@@ -32,6 +75,10 @@ void TransferFunctionView::CreateWidget(wxWindow* parent)
 void TransferFunctionView::bbUserSetDefaultValues()
 {
        mwxwidget = NULL;
+       _currentimg = NULL;
+
+       _tfun = NULL;
+       _ctfun = NULL;   
 
 }
 
@@ -39,6 +86,8 @@ void TransferFunctionView::bbUserSetDefaultValues()
        //-----------------------------------------------------------------     
        void TransferFunctionView::bbUserInitializeProcessing()
        {
+               _tfun = vtkPiecewiseFunction::New();
+               _ctfun = vtkColorTransferFunction::New();   
                bbSetInputIn(NULL);
        }