]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramDialog.cxx
*** empty log message ***
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / pPlotter / HistogramDialog.cxx
1 #include "HistogramDialog.h"
2 #include <vector>
3
4 #include "OpenImage.xpm"
5 #include "Save.xpm"
6 #include "Ok.xpm"
7 #include "Cancel.xpm"
8 #include "Edit.xpm"
9 #include "creaSystem.h"
10
11
12
13 // IMPLEMENT_CLASS(HistogramDialog, wxDialog)
14
15
16 //id for events
17 enum {
18     ID_SAVE  = 108,
19         ID_LOAD,
20         ID_REFRESH
21 };
22
23 //-------------------------
24 //Constructor
25 //-------------------------
26 HistogramDialog::HistogramDialog(wxWindow *parent,wxString title,vtkImageData* imageData,int type)
27 :wxDialog(parent,-1,title,wxDefaultPosition,wxDefaultSize,wxRESIZE_BORDER|wxDEFAULT_DIALOG_STYLE   ,_T("dialogBox"))
28 {
29
30         initializeHistogramDialog();
31         initializeHistogram(imageData);
32
33 }
34
35 HistogramDialog::HistogramDialog(wxWindow *parent,wxString title)
36 :wxDialog(parent,-1,title,wxDefaultPosition,wxDefaultSize,wxRESIZE_BORDER|wxDEFAULT_DIALOG_STYLE   ,_T("dialogBox")){
37         initializeHistogramDialog();
38 }
39
40 void HistogramDialog::initializeHistogramDialog(){
41     _ctfun=NULL;
42         _tfun=NULL;
43         _maxgreyvalue=0;
44
45         SetBackgroundColour(wxColour(255,255,255));
46         /*
47         Pointers
48         */
49         wxvtkmpr3Dview=NULL;
50         wxvtkclipping3Dview=NULL;
51         
52         /*
53          Histogram
54         */
55         
56         histogramW=new HistogramWidget(this, -1);
57         
58         /*
59         Buttons
60         */
61         wxBitmap bitmap0(Ok_xpm);
62         okBtn = new wxBitmapButton(this, wxID_OK, bitmap0,wxDefaultPosition,wxDefaultSize);             
63         
64         wxBitmap bitmap1(Cancel_xpm);
65         cancelBtn = new wxBitmapButton(this, wxID_CANCEL, bitmap1,wxDefaultPosition,wxDefaultSize);     
66         
67         //saveDataBtn = new wxButton(this,ID_SAVE,_T("Save"));
68         //loadDataBtn = new wxButton(this,ID_LOAD,_T("Load"));
69         //refreshBtn = new wxButton(this,ID_REFRESH,_T("Refresh"));
70         
71         //Connect(saveDataBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &HistogramDialog::OnSaveData     );
72         //Connect(loadDataBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &HistogramDialog::OnLoadData     );
73         //Connect(refreshBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &HistogramDialog::OnRefreshBtn    );
74         
75         //-------------------
76         //GUI
77         //-------------------
78         
79         //Upper Box
80         wxBoxSizer * upper_box = new wxBoxSizer( wxHORIZONTAL );
81         //Including components for plotter control
82         upper_box->Add( histogramW, 4, wxGROW);
83         upper_box->Add( getControls(),wxSizerFlags().Center() );
84
85         //bottom Sizer
86         wxBoxSizer *bottomBox = new wxBoxSizer( wxHORIZONTAL );
87         bottomBox->Add( okBtn, wxSizerFlags().Center());
88         bottomBox->AddSpacer(40);
89         //bottomBox->Add( saveDataBtn,wxSizerFlags().Center() );
90         //bottomBox->AddSpacer(40);
91         //bottomBox->Add( loadDataBtn,wxSizerFlags().Center() );
92         //bottomBox->AddSpacer(40);
93         //bottomBox->Add( refreshBtn,wxSizerFlags().Center() );
94         //bottomBox->AddSpacer(40);
95         bottomBox->Add( cancelBtn,wxSizerFlags().Center() );
96         
97         //Sizer
98         wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
99         sizer->Add(upper_box,1,wxEXPAND);       
100     sizer->Add(bottomBox,0,wxCENTER);
101         SetAutoLayout( TRUE );
102         SetSizer( sizer );
103         SetBestSize(wxSize(600,600));
104 }
105
106 wxSizer* HistogramDialog::getControls(){                
107                 
108         wxSizer* sizer = new wxBoxSizer(wxVERTICAL);
109         
110         wxBitmap bitmap0(OpenImage_xpm);
111         wxBitmapButton* opendata = new wxBitmapButton(this, -1, bitmap0,wxDefaultPosition,wxSize(30,30));       
112         Connect(opendata->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&HistogramDialog::OnLoadData);                  
113         sizer->Add(opendata,wxSizerFlags().Center());   
114         sizer->AddSpacer(5);
115
116         wxBitmap bitmap1(Save_xpm);
117         wxBitmapButton* savedata = new wxBitmapButton(this, -1, bitmap1,wxDefaultPosition,wxSize(30,30));       
118         Connect(savedata->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&HistogramDialog::OnSaveData);                  
119         sizer->Add(savedata,wxSizerFlags().Center());
120         sizer->AddSpacer(5);
121
122     sizer->Add(getBitmapCombo(),wxSizerFlags().Center());
123         
124         
125         
126         return sizer;
127
128
129 }
130
131 wxSizer* HistogramDialog::getBitmapCombo(){
132         _bitmapsizer = new wxBoxSizer(wxHORIZONTAL);
133
134         _bitmapcombo = getBitmapComboElements();
135
136         wxBitmap bitmap1(Edit_xpm);
137         wxBitmapButton* edit = new wxBitmapButton(this, -1, bitmap1,wxDefaultPosition,wxSize(30,30));   
138         Connect(edit->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&HistogramDialog::OnEditBitmapCombo);                       
139         
140         _bitmapsizer->Add(_bitmapcombo,wxSizerFlags().Center().FixedMinSize());
141         _bitmapsizer->Add(edit,wxSizerFlags().Center());
142
143         return _bitmapsizer;
144         
145 }
146
147 void HistogramDialog::OnEditBitmapCombo(wxCommandEvent& event){
148
149         wxBitmapComboBox* tempbitmapcombo = _bitmapcombo;
150
151         for(int i = 0; i < _bitmapsitems.size();i++){
152                 delete _bitmapsitems[i];
153         }
154         _bitmapsitems.clear();
155
156         _bitmapcombo = getBitmapComboElements();
157         if(_bitmapsizer->Replace(tempbitmapcombo,_bitmapcombo)){
158                 
159                 
160                 tempbitmapcombo->Destroy();
161         }
162         this->Layout();
163 }
164
165 wxBitmapComboBox* HistogramDialog::getBitmapComboElements(){
166         std::string currentpath = crea::System::GetDllAppPath("bbcreaMaracasVisu");     
167         currentpath.append(FILENAME);
168
169         std::vector<int> redvect,greenvect,bluevect;
170         std::vector<double> greyvect;
171
172
173         std::vector<HistogramDialogComboBoxItem*> bitmapsitems;
174         OnLoadComboBoxData(bitmapsitems, currentpath,greyvect, redvect,greenvect,bluevect);     
175         _bitmapsitems = bitmapsitems;
176         wxString* choices;
177         choices = new wxString[bitmapsitems.size()];
178         for(int i = 0; i < bitmapsitems.size();i++){
179                 choices[i] = _T("");
180         }
181         wxBitmapComboBox* bitmapcombo = new wxBitmapComboBox(this, -1, _T(""), wxDefaultPosition, wxDefaultSize, bitmapsitems.size(),choices);
182
183         Connect(bitmapcombo->GetId(), wxEVT_COMMAND_COMBOBOX_SELECTED, (wxObjectEventFunction)&HistogramDialog::OnBitmapComboItemSelected);                     
184         
185
186         for(int i = 0; i < bitmapsitems.size(); i++){
187         bitmapcombo->SetItemBitmap(i, bitmapsitems[i]->GetBitmap());
188         }
189
190         
191         return  bitmapcombo;
192 }
193 void HistogramDialog::OnBitmapComboItemSelected(wxCommandEvent& event){
194         if(_bitmapcombo!=NULL){
195                 int selecteditem = event.GetInt();              
196                 if(_bitmapsitems.size()>selecteditem){
197                         HistogramDialogComboBoxItem* currentconfig = _bitmapsitems[selecteditem];
198                         this->eraseColorPoints();
199                         for(int i = 0; i < currentconfig->getGreyVector().size();i++){
200                                 int greyv = currentconfig->getGreyVector()[i]*_maxgreyvalue;
201                                 int red = currentconfig->getRedVector()[i];
202                                 int green = currentconfig->getGreenVector()[i];
203                                 int blue = currentconfig->getBlueVector()[i];
204
205                                 this->addColorPoint(greyv, red, green, blue);
206                         }
207                 }
208                 
209         }
210 }
211 std::vector<wxBitmap*> HistogramDialog::GetBitmapsList(std::vector<double> greyvect, std::vector<int> redvect, std::vector<int> greenvect, std::vector<int> bluevect){
212
213         std::vector<wxBitmap*> bitmaps;
214         for(int i = 0; i < greyvect.size();i++){
215         //bitmaps.push_back();
216         }
217 }
218 void HistogramDialog::OnLoadComboBoxData(std::vector<HistogramDialogComboBoxItem*>& itembitmaps, std::string filename, std::vector<double>& greyvect, std::vector<int>& redvect, std::vector<int>& greenvect, std::vector<int>& bluevect){    
219
220         
221         std::ifstream file;     
222         file.open(  (const char*) (filename.c_str()) ); 
223         double gv=-1;
224         int in=-1,red=-1,gr=-1,bl=-1;
225
226         std::cout<<filename<<std::endl;
227         itembitmaps.clear();
228         if(file.is_open())
229         {       
230                 bool add = false;
231                 HistogramDialogComboBoxItem* item=NULL;
232                 while(!file.eof())
233                 {
234                         std::string line;
235                         std::getline(file,line);
236
237             if( (int)(line.find("<Colors>")!=-1))
238                         {
239                                 item = new HistogramDialogComboBoxItem();
240                         }else if( (int)(line.find("RGBgreyValue"))!=-1)
241                         {
242                                 int pos1=line.find(">");
243                                 int pos2=line.find("<",pos1+1);
244                                 std::string x=line.substr(pos1+1,pos2-pos1-1);
245                                 gv=atof(x.c_str());                             
246                                 
247                         }
248                         else if( (int)(line.find("red"))!=-1)
249                         {
250                                 int pos1=line.find(">");
251                                 int pos2=line.find("<",pos1+1);
252                                 std::string x=line.substr(pos1+1,pos2-pos1-1);
253                                 red=atoi(x.c_str());
254                                 
255                         }
256                         else if( (int)(line.find("green"))!=-1)
257                         {
258                                 int pos1=line.find(">");
259                                 int pos2=line.find("<",pos1+1);
260                                 std::string x=line.substr(pos1+1,pos2-pos1-1);
261                                 gr=atoi(x.c_str());
262                         }
263                         else if( (int)(line.find("blue"))!=-1 )
264                         {
265                                 int pos1=line.find(">");
266                                 int pos2=line.find("<",pos1+1);
267                                 std::string x=line.substr(pos1+1,pos2-pos1-1);
268                                 bl=atoi(x.c_str());                                                             
269                                 greyvect.push_back(gv);
270                                 redvect.push_back(red);
271                                 greenvect.push_back(gr);
272                                 bluevect.push_back(bl);
273                         }else if( (int)(line.find("</Colors>"))!=-1 ){
274
275                                 item->SetColors(greyvect,redvect,greenvect,bluevect);
276
277                                 itembitmaps.push_back(item);
278
279                                 greyvect.clear();
280                                 redvect.clear();
281                                 greenvect.clear();
282                                 bluevect.clear();
283
284                         }
285                         
286                         line.clear();
287                 }
288                 file.close();                   
289                 std::cout<<itembitmaps.size()<<std::endl;
290      }  
291         
292 }
293 //-----------------------
294 //Handling events
295 //-----------------------
296
297 void HistogramDialog::OnSaveData(wxCommandEvent& event)
298 {
299         wxString nameF=wxFileSelector(_T("Save Data"), _T(" "),_T(""),_T(""),_T("*.*"),wxSAVE, NULL, -1,  -1);//wxFileSelector(_T("Save Data"),wxSAVE);
300         std::ofstream file;
301         if(nameF.CompareTo( _T("/0") )>0)
302                 file.open( (const char*)(nameF.mb_str()) );
303
304         if(file.is_open())
305         {
306                 file << "<histogram Data>" << std::endl;
307                 //histograms points
308                 /*
309                 file << "       <histogramPoints>" << std::endl;
310                 int histogramS=histogramW->getHistogramSize();
311                 int i=0;        
312                 while(i<histogramS)
313                 {
314                         file << "               <HistogramPoint>" << std::endl;
315                         file << "                       <greyValue>" << i << "</greyValue>" <<std::endl;
316                         file << "                       <number>" << histogramW->getHistogramPoint(i) << "</number>"<<std::endl;
317                         file << "               </HistogramPoint>" << std::endl;
318                         i++;
319                 }
320                 file << "       </histogramPoints>" << std::endl;
321                 */
322                 //points transference Function
323                 file << " <TransferenceFunction>"<< std::endl;
324                 int tfPointS=histogramW->getSizeTransferenceFunction();
325                 int i=0;
326                 int gv,in;
327                 while(i<tfPointS)
328                 {
329                         
330                         histogramW->getTransferenceFunctionPoint(i,gv,in);
331                         file << "               <Transferencepoint>" << std::endl;
332                         file << "                       <greyValue>" << gv << "</greyValue>" <<std::endl;
333                         file << "                       <intensity>" << in << "</intensity> "<<std::endl;
334                         file << "               </Transferencepoint>" << std::endl;
335                         i++;
336                 }
337                 file << "       </TransferenceFunction>"<< std::endl;
338                 //colorPoints
339                 file << "       <Colors>"<< std::endl;
340                 int ctfPointS=histogramW->getSizeBarColor();
341
342                 i=0;
343                 int red,green,blue;
344                 while(i<ctfPointS)
345                 {
346                         
347                         histogramW->getDataBarColorPoint(i,gv,red,green,blue);
348                         file << "               <greyValueRGBpoint>" << std::endl;
349                         file << "                       <RGBgreyValue>" << gv << "</RGBgreyValue>" <<std::endl;
350                         file << "                       <red>" << red << "</red>" <<std::endl;
351                         file << "                       <green>" << green << "</green>" <<std::endl;
352                         file << "                       <blue>" << blue << "</blue>" <<std::endl;
353                         file << "               </greyValueRGBpoint>" << std::endl;
354                         i++;
355                 }
356
357                 file << "       </Colors>"<< std::endl;
358                 file << "</histogram Data>" << std::endl;
359         }
360         file.close();
361 }
362
363 void HistogramDialog::OnLoadData(wxCommandEvent& event)
364 {
365         wxString nameF=wxFileSelector(_T("Load Data") );
366         //std::string line;
367         std::ifstream file;
368         if(nameF.CompareTo( _T("/0") )>0)
369                 file.open(  (const char*) (nameF.mb_str()) );
370         
371         bool histogramReading=false,/*histogramPoints=false,histogramPoint=false,*/tf=false,ctf=false,tfp=false,ctfp=false;  // JPRx
372         int gv=-1,in=-1,red=-1,gr=-1,bl=-1/*,nPoints=-1*/; // JPRx
373         if(file.is_open())
374         {
375                 //-------------
376                 erasePointsTransferenceFunction();
377                 eraseColorPoints();
378                 //--------------
379         
380                 //std::getline(file,line);
381                 //int i=0;  // JPRx
382                 while(!file.eof())
383                 {
384                         std::string line;
385                         std::getline(file,line);
386                         //int a=line.find("histogram Data");
387                         if( (int)(line.find("histogram Data"))!=-1)
388                         {
389                                 histogramReading=true;
390                         
391                         }
392                         /*
393                         else if(line.find("histogramPoints")!=0 && histogramReading)
394                         {
395                                 histogramPoints=true;
396                         }
397                         else if(line.find("histogramPoint")!=0 && histogramReading && histogramPoints)
398                         {
399
400                         }
401                         else if(line.find("greyValue")!=0 && histogramReading && histogramPoints)
402                         {
403                                 int pos1=line.find(">");
404                                 int pos2=line.find("<",pos+1);
405                                 std::string x=line.substr(pos1+1,pos2-1);
406                                 gv=atoi(x.c_str());
407                         }
408                         else if(line.find("number")!=0 && histogramReading && histogramPoints)
409                         {
410                                 int pos1=line.find(">");
411                                 int pos2=line.find("<",pos+1);
412                                 std::string x=line.substr(pos1+1,pos2-1);
413                                 nP=atoi(x.c_str());
414                                 //add to the histogram
415                                 //histogramW->addPointToTransferenceFunction(gc,in);
416                         }
417                         */
418                         else if( (int)(line.find("TransferenceFunction"))!=-1 && histogramReading)
419                         {
420                                 tf=true;
421                         }
422                         else if( (int)(line.find("<Transferencepoint>"))!=-1 && histogramReading && tf)
423                         {
424                                 tfp=true;
425                         }
426                         else if( (int)(line.find("greyValue"))!=-1 && histogramReading && tf && tfp)
427                         {
428                                 int pos1=line.find(">");
429                                 int pos2=line.find("<",pos1+1);
430                                 std::string x=line.substr(pos1+1,pos2-pos1-1);
431                                 gv=atoi(x.c_str());
432                                 
433                         }
434                         else if( (int)(line.find("intensity"))!=-1 && histogramReading && tf && tfp)
435                         {
436                                 int pos1=line.find(">");
437                                 int pos2=line.find("<",pos1+1);
438                                 std::string x=line.substr(pos1+1,pos2-pos1-1);
439                                 in=atoi(x.c_str());
440                                 histogramW->addPointToTransferenceFunction(gv,in);
441                                 tfp=false;
442                                 
443                         }
444                         else if( (int)(line.find("Colors"))!=-1 && histogramReading)
445                         {
446                                 ctf=true;
447                         }
448                         
449                         else if( (int)(line.find("greyValueRGBpoint"))!=-1 && histogramReading && ctf )
450                         {
451                                 ctfp=true;
452                                 
453                         }
454                         else if( (int)(line.find("RGBgreyValue"))!=-1 && histogramReading && ctf && ctfp)
455                         {
456                                 int pos1=line.find(">");
457                                 int pos2=line.find("<",pos1+1);
458                                 std::string x=line.substr(pos1+1,pos2-pos1-1);
459                                 gv=atoi(x.c_str());
460                                 
461                         }
462                         else if( (int)(line.find("red"))!=-1 && histogramReading && ctf && ctfp)
463                         {
464                                 int pos1=line.find(">");
465                                 int pos2=line.find("<",pos1+1);
466                                 std::string x=line.substr(pos1+1,pos2-pos1-1);
467                                 red=atoi(x.c_str());
468                                 
469                         }
470                         else if( (int)(line.find("green"))!=-1 && histogramReading && ctf && ctfp)
471                         {
472                                 int pos1=line.find(">");
473                                 int pos2=line.find("<",pos1+1);
474                                 std::string x=line.substr(pos1+1,pos2-pos1-1);
475                                 gr=atoi(x.c_str());
476                         }
477                         else if( (int)(line.find("blue"))!=-1 && histogramReading && ctf && ctfp)
478                         {
479                                 int pos1=line.find(">");
480                                 int pos2=line.find("<",pos1+1);
481                                 std::string x=line.substr(pos1+1,pos2-pos1-1);
482                                 bl=atoi(x.c_str());
483                                 histogramW->addColorPoint(gv,red,gr,bl);
484                                 ctfp=false;
485                         }
486                         line.clear();
487              }
488      }
489         
490         file.close();
491         histogramW->updatePlotter();
492 }
493 /*
494  On refresh btn
495 */
496
497 void HistogramDialog::OnRefreshBtn(wxCommandEvent &event)
498 {
499         refreshed=true;
500                         
501                         int i=0,xi,yi,r,g,b;
502                         
503                         // -- TransferenceFunction --
504                         int nPointsTF=getSizeTransferenceFunction();
505
506                         if(nPointsTF>0)
507                         {
508
509                                 int nTFPoints=getSizeTransferenceFunction();
510                                 i=0;
511                                 while(i<nTFPoints)
512                                 {
513                                         getTransferenceFunctionPoint(i,xi,yi);
514                                         _tfun->AddPoint( xi , yi/100.0 );
515                                         i++;
516                                 }
517                         }
518                         //-- Color bar --
519                         //clean colors
520                         int nPointsCTF=getSizeBarColor();
521                         if(nPointsCTF>0)
522                         {                       
523                                 _ctfun->RemoveAllPoints();
524                                 
525                                 int nCTFpoints=getSizeBarColor();
526                                 i=0;    
527                                 while(i<nCTFpoints)
528                                 {
529                                         getDataBarColorPoint(i,xi,r,g,b);
530                                         _ctfun->AddRGBPoint(xi,r/255.0,g/255.0,b/255.0 );
531                                         i++;
532                                 }
533                         }
534
535 //EED Borrame
536
537         /*
538          NOTE I NEED THE UPDATE
539         */
540         //if it was call from the clipping ctnrl panel
541         if(wxvtkclipping3Dview!=NULL)
542         {
543                 wxvtkclipping3Dview->Refresh();
544
545         }
546         else if(wxvtkmpr3Dview!=NULL)
547         {
548                 wxvtkmpr3Dview->Refresh();
549
550         }
551 }
552
553
554 //-----------------------
555 //Methods
556 //-----------------------
557
558 /*
559                 get number of points of the transference function
560         */
561         int HistogramDialog::getSizeTransferenceFunction()
562         {
563                 return histogramW->getSizeTransferenceFunction();
564                 
565         }
566         /*
567                 get number of points of the barColor
568         */
569         int HistogramDialog::getSizeBarColor()
570         {
571                 return histogramW->getSizeBarColor();
572         }
573         /*
574                 get a point of the transference function
575         */
576         void HistogramDialog::getTransferenceFunctionPoint(int index,int& x,int& y)
577         {
578                 histogramW->getTransferenceFunctionPoint(index,x,y);
579         }
580         /*
581                 get a  color int the bqr color
582         */
583         void HistogramDialog::getDataBarColorPoint(int index,int&x, int& red,int& green,int& blue)
584         {
585                 histogramW->getDataBarColorPoint(index,x,red,green,blue);
586         }
587         /*
588                 get a point of the Histogram
589                 given the grey value
590         */
591         int HistogramDialog::getHistogramPoint(int gValue)
592         {
593                 return histogramW->getHistogramPoint(gValue);
594         }
595
596         //--------------------
597         // bar Information
598         //---------------------
599         /*
600          Get the porcentage of the positions of 
601          the min,max and actual in the bar range
602         */
603         float HistogramDialog::getMaxShowedPorcentage()
604         {
605                 return histogramW->getMaxShowedPorcentage();
606         }
607         float HistogramDialog::getMinShowedPorcentage()
608         {
609                 return histogramW->getMinShowedPorcentage();
610         }
611         float HistogramDialog::getActualShowedPorcentage()
612         {
613                 return histogramW->getActualShowedPorcentage();
614         }
615         //---------------------------------------
616         // setting data in transferences function
617         // and in bar color
618         //----------------------------------------
619         bool  HistogramDialog::addPointToTransferenceFunction(double x, double y)
620         {
621                 return histogramW->addPointToTransferenceFunction(x,y);
622         }
623         bool  HistogramDialog::addColorPoint(double x,int red,int green, int blue)
624         {
625                 return histogramW->addColorPoint(x,red,green,blue);
626         }
627         //------------------------
628         //Erase data
629         //------------------------
630         
631         /*
632          Erase all the points that are in the transference function
633         */
634         void HistogramDialog::erasePointsTransferenceFunction()
635         {
636                 histogramW->erasePointsTransferenceFunction();
637         }
638         /*
639         Erase the  color points in the plotter
640         */
641         void HistogramDialog::eraseColorPoints()
642         {
643                 histogramW->eraseColorPoints();
644         }
645
646         //-------------------
647         // Getter and setters
648         //-------------------
649
650         void HistogramDialog::setCTF(vtkColorTransferFunction *cf)
651         {
652                 _ctfun=cf;
653         
654         }
655         void HistogramDialog:: setTF(vtkPiecewiseFunction *tf)
656         {
657                 _tfun=tf;
658         }
659
660         bool HistogramDialog::getRefreshed()
661         {
662                 return refreshed;
663         }
664         
665         void HistogramDialog::setVolumeMapper(vtkVolumeRayCastMapper* volMapper)
666         {
667                 volumeMapper=volMapper;
668         }
669         void HistogramDialog::setVolume(vtkVolume* vol)
670         {
671                 newvol=vol;     
672         }
673         void HistogramDialog::setMPR3Dview(wxVtkMPR3DView *wxvtkmpr3Dview1)
674         {
675                 wxvtkmpr3Dview=wxvtkmpr3Dview1;
676         }
677         void HistogramDialog::setClipping3DView(wxVtkClipping3DView *wxvtkclipping3Dview1)
678         {
679                 wxvtkclipping3Dview=wxvtkclipping3Dview1;
680         }
681
682
683         void  HistogramDialog::setTransferenceFunctionHasPoints(bool hasPoints)
684         {
685                 histogramW->setTransferenceFunctionHasPoints(hasPoints);
686         }
687         void  HistogramDialog::setTransferenceFunctionHasColor(bool hasColorPoints)
688         {
689                 histogramW->setTransferenceFunctionHasColor(hasColorPoints);
690         }
691
692         //--------------------
693         // plotter Information
694         //---------------------
695         void  HistogramDialog::updatePlotter()
696         {
697                 histogramW->updatePlotter();
698         }
699
700
701 /**
702 **      Initialize the histogram 
703 */
704         void HistogramDialog::initializeHistogram(vtkImageData* img){
705                 _maxgreyvalue = img->GetScalarRange()[1];
706                 histogramW->initializeHistogram(img);
707         }
708 /**
709 **      Returns two vectors, the grey level of the point and its value, the value is between [0,1]
710 **/
711         void HistogramDialog::GetValuesPointsFunction(std::vector<double>& greylevel,std::vector<double>& value){
712
713                 histogramW->GetValuesPointsFunction(greylevel, value);
714         }
715
716 /**
717 **      Returns two vectors, the grey level of the point and its value, the red, green
718 **      and blue value is between [0,1]
719 **/
720 void HistogramDialog::GetValuesColorPointsFunction(std::vector<double>& greylevel,
721                                                                 std::vector<double>& red,
722                                                                 std::vector<double>& green,
723                                                                 std::vector<double>& blue)
724 {
725         histogramW->GetValuesColorPointsFunction(greylevel, red, green, blue);
726 }
727
728 void HistogramDialog::SetFunctions(vtkPiecewiseFunction* _opac, vtkColorTransferFunction* _color){
729         _tfun = _opac;
730         _ctfun = _color;        
731 }