]> Creatis software - creaMaracasVisu.git/blob - bbtk/src/bbmaracasvisuTransferFunctionView.cxx
TransferFunctionfinish
[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->setImageData(_currentimg);   
29                         //mwxwidget->Refresh(); 
30                 }               
31
32                 mwxwidget->GetValuesPointsFunction(greylevel, value);
33                 mwxwidget->GetValuesColorPointsFunction(greylevelcolors,red, green,blue);
34
35
36                 _tfun->RemoveAllPoints();
37                 for(int i = 0; i < greylevel.size();i++){
38                         _tfun->AddPoint(greylevel[i], value[i]);
39                         std::cout<<"TransferFunctionView::Process()transfer function "<<greylevel[i]<<" "<< value[i]<<std::endl;
40                 }
41                 _ctfun->RemoveAllPoints();
42                 for(int i = 0; i < greylevelcolors.size();i++){
43                         _ctfun->AddRGBPoint(greylevelcolors[i], red[i],green[i], blue[i]);
44                 std::cout<<"TransferFunctionView::Process()transfer color function "<<greylevelcolors[i]<<" "<<red[i]<<" "<<green[i]<<" "<<blue[i]<<std::endl;
45                 }               
46
47
48                 bbSetOutputOpacityFunction(_tfun);
49                 bbSetOutputColorFunction(_ctfun);
50                 /*bbSetOutputGreyLevel(greylevel);
51                 bbSetOutputValue(value);
52                 bbSetOutputGreyLevelColors(greylevelcolors);
53                 bbSetOutputRed(red);
54                 bbSetOutputGreen(green);
55                 bbSetOutputBlue(blue);*/
56
57
58
59
60         }
61         
62     
63 }
64
65 //-----------------------------------------------------
66 void TransferFunctionView::CreateWidget(wxWindow* parent)
67 {
68         bbtkDebugMessageInc("Core",9,"TransferFunctionView::CreateWxWindow()"<<std::endl);
69
70         //mwxwidget = new HistogramWidget(parent, -1);
71         mwxwidget = new HistogramDialogComboBox(parent);
72
73     bbtkDebugDecTab("Core",9);
74         bbSetOutputWidget( mwxwidget ); 
75 }
76
77 //-----------------------------------------------------
78 void TransferFunctionView::bbUserSetDefaultValues()
79 {
80         mwxwidget = NULL;
81         _currentimg = NULL;
82
83         _tfun = NULL;
84         _ctfun = NULL;   
85
86         bbSetOutputOpacityFunction(0);
87         bbSetOutputColorFunction(0);
88
89 }
90
91         
92         //-----------------------------------------------------------------     
93         void TransferFunctionView::bbUserInitializeProcessing()
94         {
95                 _tfun = vtkPiecewiseFunction::New();
96                 _ctfun = vtkColorTransferFunction::New();   
97                 bbSetInputIn(NULL);
98         }
99         
100         //-----------------------------------------------------------------     
101         void TransferFunctionView::bbUserFinalizeProcessing()
102         {
103         }
104         
105         //-----------------------------------------------------------------     
106
107 }
108 // EO namespace bbcreaMaracasVisu
109
110