]> Creatis software - creaMaracasVisu.git/blob - bbtk/src/bbmaracasvisuTransferFunctionView.cxx
ViewerNV 2D with color Transfer Function
[creaMaracasVisu.git] / bbtk / src / bbmaracasvisuTransferFunctionView.cxx
1 #include "bbmaracasvisuTransferFunctionView.h"
2 #include "bbcreaMaracasVisuPackage.h"
3 namespace bbcreaMaracasVisu
4 {
5
6 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,TransferFunctionView)
7 BBTK_BLACK_BOX_IMPLEMENTATION(TransferFunctionView,bbtk::WxBlackBox);
8
9 //-----------------------------------------------------
10 void TransferFunctionView::Process()
11 {
12
13         std::vector<double> greylevel;
14         std::vector<double> value;
15
16         std::vector<double> greylevelcolors;
17         std::vector<double> red;
18         std::vector<double> green;
19         std::vector<double> blue;
20
21         
22
23         if(bbGetInputIn()!=NULL){
24
25                 if(_currentimg != bbGetInputIn()){
26                         _currentimg =  bbGetInputIn();
27                         mwxwidget->initializeHistogram(_currentimg);    
28                         mwxwidget->Refresh();   
29                 }               
30
31                 mwxwidget->GetValuesPointsFunction(greylevel, value);
32                 mwxwidget->GetValuesColorPointsFunction(greylevelcolors,red, green,blue);
33
34
35                 _tfun->RemoveAllPoints();
36                 for(int i = 0; i < greylevel.size();i++){
37                         _tfun->AddPoint(greylevel[i], value[i]);
38 //                      std::cout<<"transfer function "<<greylevel[i]<<" "<< value[i]<<std::endl;
39                 }
40                 _ctfun->RemoveAllPoints();
41                 for(int i = 0; i < greylevelcolors.size();i++){
42                         _ctfun->AddRGBPoint(greylevelcolors[i], red[i],green[i], blue[i]);
43 //                      std::cout<<"transfer color function "<<greylevelcolors[i]<<" "<<red[i]<<" "<<green[i]<<" "<<blue[i]<<std::endl;
44                 }               
45
46
47                 bbSetOutputOpacityFunction(_tfun);
48                 bbSetOutputColorFunction(_ctfun);
49                 /*bbSetOutputGreyLevel(greylevel);
50                 bbSetOutputValue(value);
51                 bbSetOutputGreyLevelColors(greylevelcolors);
52                 bbSetOutputRed(red);
53                 bbSetOutputGreen(green);
54                 bbSetOutputBlue(blue);*/
55
56
57
58
59         }
60         
61     
62 }
63
64 //-----------------------------------------------------
65 void TransferFunctionView::CreateWidget(wxWindow* parent)
66 {
67         bbtkDebugMessageInc("Core",9,"TransferFunctionView::CreateWxWindow()"<<std::endl);
68
69         mwxwidget = new HistogramWidget(parent, -1);
70     bbtkDebugDecTab("Core",9);
71         bbSetOutputWidget( mwxwidget ); 
72 }
73
74 //-----------------------------------------------------
75 void TransferFunctionView::bbUserSetDefaultValues()
76 {
77         mwxwidget = NULL;
78         _currentimg = NULL;
79
80         _tfun = NULL;
81         _ctfun = NULL;   
82
83         bbSetOutputOpacityFunction(0);
84         bbSetOutputColorFunction(0);
85
86 }
87
88         
89         //-----------------------------------------------------------------     
90         void TransferFunctionView::bbUserInitializeProcessing()
91         {
92                 _tfun = vtkPiecewiseFunction::New();
93                 _ctfun = vtkColorTransferFunction::New();   
94                 bbSetInputIn(NULL);
95         }
96         
97         //-----------------------------------------------------------------     
98         void TransferFunctionView::bbUserFinalizeProcessing()
99         {
100         }
101         
102         //-----------------------------------------------------------------     
103
104 }
105 // EO namespace bbcreaMaracasVisu
106
107