1 #include "bbmaracasvisuTransferFunctionView.h"
2 #include "bbcreaMaracasVisuPackage.h"
3 namespace bbcreaMaracasVisu
6 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,TransferFunctionView)
7 BBTK_BLACK_BOX_IMPLEMENTATION(TransferFunctionView,bbtk::WxBlackBox);
9 //-----------------------------------------------------
10 void TransferFunctionView::Process()
17 if(bbGetInputIn()!=NULL){
19 if(_currentimg != bbGetInputIn()){
20 _currentimg = bbGetInputIn();
21 //mwxwidget->initializeHistogram(_currentimg);
22 mwxwidget->setImageData(_currentimg);
23 //mwxwidget->Refresh();
28 /*bbSetOutputGreyLevel(greylevel);
29 bbSetOutputValue(value);
30 bbSetOutputGreyLevelColors(greylevelcolors);
32 bbSetOutputGreen(green);
33 bbSetOutputBlue(blue);*/
43 void TransferFunctionView::onColorChange(){
45 std::vector<double> greylevel;
46 std::vector<double> value;
48 std::vector<double> greylevelcolors;
49 std::vector<double> red;
50 std::vector<double> green;
51 std::vector<double> blue;
53 mwxwidget->GetValuesPointsFunction(greylevel, value);
54 mwxwidget->GetValuesColorPointsFunction(greylevelcolors,red, green,blue);
57 _tfun->RemoveAllPoints();
58 for(int i = 0; i < greylevel.size();i++){
59 _tfun->AddPoint(greylevel[i], value[i]);
60 //std::cout<<"TransferFunctionView::Process()transfer function "<<greylevel[i]<<" "<< value[i]<<std::endl;
62 _ctfun->RemoveAllPoints();
63 for(int i = 0; i < greylevelcolors.size();i++){
64 _ctfun->AddRGBPoint(greylevelcolors[i], red[i],green[i], blue[i]);
65 //std::cout<<"TransferFunctionView::Process()transfer color function "<<greylevelcolors[i]<<" "<<red[i]<<" "<<green[i]<<" "<<blue[i]<<std::endl;
68 bbSignalOutputModification();
70 bbSetOutputOpacityFunction(_tfun);
71 bbSetOutputColorFunction(_ctfun);
74 void TransferFunctionView::onSliderChange(){
79 bbSignalOutputModification();
81 bbSetOutputWindowLevel(mwxwidget->GetWindowLevel());
82 bbSetOutputColorLevel(mwxwidget->GetColorLevel());
86 //-----------------------------------------------------
87 void TransferFunctionView::CreateWidget(wxWindow* parent)
89 bbtkDebugMessageInc("Core",9,"TransferFunctionView::CreateWxWindow()"<<std::endl);
91 mwxwidget = new HistogramDialogComboBox(parent);
94 HandlerTransferFunctionView* handler = new HandlerTransferFunctionView(this);
96 parent->Connect(mwxwidget->GetId(), wxEVT_COMMAND_COMBOBOX_SELECTED, (wxObjectEventFunction) (&HandlerTransferFunctionView::onColorChange),NULL,handler);
97 parent->Connect(mwxwidget->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction) (&HandlerTransferFunctionView::onSliderChange),NULL,handler);
99 bbtkDebugDecTab("Core",9);
100 bbSetOutputWidget( mwxwidget );
103 //-----------------------------------------------------
105 void TransferFunctionView::bbUserSetDefaultValues()
113 bbSetOutputOpacityFunction(0);
114 bbSetOutputColorFunction(0);
119 //-----------------------------------------------------------------
120 void TransferFunctionView::bbUserInitializeProcessing()
122 _tfun = vtkPiecewiseFunction::New();
123 _ctfun = vtkColorTransferFunction::New();
127 //-----------------------------------------------------------------
128 void TransferFunctionView::bbUserFinalizeProcessing()
133 //-----------------------------------------------------------------
136 HandlerTransferFunctionView::HandlerTransferFunctionView(TransferFunctionView* box){
139 HandlerTransferFunctionView::~HandlerTransferFunctionView(){
142 void HandlerTransferFunctionView::onColorChange(wxCommandEvent& event){
143 _box->onColorChange();
145 void HandlerTransferFunctionView::onSliderChange(wxCommandEvent& event){
146 _box->onSliderChange();
152 // EO namespace bbcreaMaracasVisu