]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/HistogramDialogComboBox.cxx
*** empty log message ***
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / pPlotter / HistogramDialogComboBox.cxx
index f3586470487e8fa0a41d04224efc243715d2da74..4730763c14a87ca48b1c1c69414c7d7a683c04eb 100644 (file)
@@ -11,7 +11,7 @@
 HistogramDialogComboBox::HistogramDialogComboBox(wxWindow* parent)
 : wxPanel(parent)
 {
-       _img                            = NULL; 
+       _img                    = NULL; 
        _bitmapcombo            = NULL;
        _slidercolor            = NULL;
        _sliderwindowlevel      = NULL; 
@@ -19,10 +19,15 @@ HistogramDialogComboBox::HistogramDialogComboBox(wxWindow* parent)
        _bitmapsizer            = NULL;
 
        this->SetSizer(getBitmapCombo());
-       _img                            = NULL;
+       _img                    = NULL;
        _currentitem            = -1;
        _maxgreyvalue           = 0;
 printf("EED HistogramDialogComboBox\n");       
+#ifdef LINUX
+       std::string currentpath = crea::System::GetExecutablePath();
+       currentpath.append("/data/");
+       crea::System::createDirectory(currentpath.c_str());
+#endif
 }
 
 HistogramDialogComboBox::~HistogramDialogComboBox()
@@ -52,7 +57,6 @@ wxSizer* HistogramDialogComboBox::getBitmapCombo()
        comboeditsizer->Add(_bitmapcombo,wxSizerFlags().Center().FixedMinSize());
        comboeditsizer->Add(edit,wxSizerFlags().Center());
 
-
        _bitmapsizer->Add(comboeditsizer,wxSizerFlags().FixedMinSize().Center());
        _bitmapsizer->AddSpacer(5);
        _bitmapsizer->Add(getSlidersWlCo(),wxSizerFlags().Expand().Center());
@@ -60,7 +64,8 @@ wxSizer* HistogramDialogComboBox::getBitmapCombo()
        return _bitmapsizer;
 }
 
-wxSizer* HistogramDialogComboBox::getSlidersWlCo(){
+wxSizer* HistogramDialogComboBox::getSlidersWlCo()
+{
        wxBoxSizer* sizersliders = new wxBoxSizer(wxVERTICAL);
 
        _slidercolor = new wxSlider(this, -1,1,0,1,wxDefaultPosition,wxDefaultSize,wxSL_LABELS);
@@ -69,7 +74,7 @@ wxSizer* HistogramDialogComboBox::getSlidersWlCo(){
        sizersliders->Add(_slidercolor,wxSizerFlags().Expand().Center());
        sizersliders->Add(_sliderwindowlevel,wxSizerFlags().Expand().Center());
 
-    Connect(_slidercolor->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction)&HistogramDialogComboBox::OnColorLevelChanged);
+       Connect(_slidercolor->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction)&HistogramDialogComboBox::OnColorLevelChanged);
        Connect(_sliderwindowlevel->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction)&HistogramDialogComboBox::OnWindowLevelChanged);
 
        return sizersliders;
@@ -77,39 +82,39 @@ wxSizer* HistogramDialogComboBox::getSlidersWlCo(){
 
 double HistogramDialogComboBox::GetWindowLevel()
 {
-       if(_sliderwindowlevel != NULL)
-       {
-               return _sliderwindowlevel->GetValue();
-       }
+   double val(0.0);
+   if(_sliderwindowlevel != NULL)
+      val= _sliderwindowlevel->GetValue();     
+   return val; // JPR
 }
 
 double HistogramDialogComboBox::GetColorLevel()
 {
-    if(_slidercolor != NULL)
-       {
-               return _slidercolor->GetValue();
-       }    
+   double val(0.0);
+   if(_slidercolor != NULL)
+      val = _slidercolor->GetValue();
+   return val; // JPR   
 }
 
 void HistogramDialogComboBox::OnColorLevelChanged(wxCommandEvent& event)
 {
-       _slidercolor->GetValue();
-       wxCommandEvent newevent(wxEVT_SCROLL_THUMBTRACK,this->GetId());
-       ProcessEvent(newevent);
+   _slidercolor->GetValue();
+   wxCommandEvent newevent(wxEVT_SCROLL_THUMBTRACK,this->GetId());
+   ProcessEvent(newevent);
 }
 
 void HistogramDialogComboBox::OnWindowLevelChanged(wxCommandEvent& event)
 {
-       _sliderwindowlevel->GetValue();
-       wxCommandEvent newevent(wxEVT_SCROLL_THUMBTRACK,this->GetId());
-    ProcessEvent(newevent);
+   _sliderwindowlevel->GetValue();
+   wxCommandEvent newevent(wxEVT_SCROLL_THUMBTRACK,this->GetId());
+   ProcessEvent(newevent);
 }
 
 void HistogramDialogComboBox::setImageData(vtkImageData* img)
 {
-       _maxgreyvalue = img->GetScalarRange()[1];
-       _img = img;
-       setSlidersValue();
+   _maxgreyvalue = img->GetScalarRange()[1];
+   _img = img;
+   setSlidersValue();
 }
 
 void HistogramDialogComboBox::setSlidersValue()
@@ -127,7 +132,7 @@ void HistogramDialogComboBox::setSlidersValue()
 }
 
 void HistogramDialogComboBox::OnEditBitmapCombo(wxCommandEvent& event)
-{      
+{
        if(_img!=NULL)
        {
                bool createaddandremovecontrols = true;
@@ -137,12 +142,20 @@ void HistogramDialogComboBox::OnEditBitmapCombo(wxCommandEvent& event)
 
                if(dialog->ShowModal()==wxID_OK)
                {
-                       
                        dialog->UpdateCurrentComboElement();
                        _bitmapsitems = dialog->getComboBoxItems();
                        
-
-                       std::string currentpath = crea::System::GetDllAppPath("bbcreaMaracasVisu");     
+                       //std::string currentpath = crea::System::GetDllAppPath("bbcreaMaracasVisu"); // JPR
+                       std::string dllLastName;
+                       std::string currentpath;
+                       #ifdef WIN32
+                       dllLastName = "bbcreaMaracasVisu";
+                       currentpath = crea::System::GetDllAppPath(dllLastName);
+                       #endif
+                       #ifdef LINUX
+                       currentpath = crea::System::GetExecutablePath();
+                       currentpath.append("/data/");
+                       #endif
                        currentpath.append(FILENAME);
 
                        std::vector<double> redvect,greenvect,bluevect;
@@ -226,6 +239,10 @@ wxBitmapComboBox* HistogramDialogComboBox::getBitmapComboElements()
        std::string currentpath = "";
 #ifdef WIN32
        currentpath = crea::System::GetDllAppPath("bbcreaMaracasVisu"); 
+#endif
+#ifdef LINUX
+       currentpath = crea::System::GetExecutablePath();
+       currentpath.append("/data/");
 #endif
        currentpath.append(FILENAME);
        
@@ -301,81 +318,81 @@ void HistogramDialogComboBox::OnLoadComboBoxData(std::vector<HistogramDialogComb
                        std::getline(file,line);
                        //std::cout<<line<<std::endl;
             if( (int)(line.find("<ComboBoxItem>")!=-1))
-                       {
-                               item = new HistogramDialogComboBoxItem();
-                       }else if((int)(line.find("<greyValue>"))!=-1){
-                int pos1=line.find(">");
-                               int pos2=line.find("<",pos1+1);
-                               std::string x=line.substr(pos1+1,pos2-pos1-1);
-                               gvtransfer=atof(x.c_str());                             
-                               greyvecttransfunct.push_back(gvtransfer);
-                       }else if((int)(line.find("<intensity>"))!=-1){
-                int pos1=line.find(">");
-                               int pos2=line.find("<",pos1+1);
-                               std::string x=line.substr(pos1+1,pos2-pos1-1);
-                               intensity=atof(x.c_str());                                      
-                               value.push_back(intensity);
-                       }
-                       else if( (int)(line.find("<RGBgreyValue>"))!=-1)
-                       {
-                               int pos1=line.find(">");
-                               int pos2=line.find("<",pos1+1);
-                               std::string x=line.substr(pos1+1,pos2-pos1-1);
-                               gv=atof(x.c_str());                             
-                               greyvect.push_back(gv);                         
-                       }
-                       else if( (int)(line.find("<red>"))!=-1)
-                       {
-                               int pos1=line.find(">");
-                               int pos2=line.find("<",pos1+1);
-                               std::string x=line.substr(pos1+1,pos2-pos1-1);
-                               red=atof(x.c_str());
-                               redvect.push_back(red);                         
-                       }
-                       else if( (int)(line.find("<green>"))!=-1)
-                       {
-                               int pos1=line.find(">");
-                               int pos2=line.find("<",pos1+1);
-                               std::string x=line.substr(pos1+1,pos2-pos1-1);
-                               gr=atof(x.c_str());
-                               greenvect.push_back(gr);
-                       }
-                       else if( (int)(line.find("<blue>"))!=-1 )
-                       {
-                               int pos1=line.find(">");
-                               int pos2=line.find("<",pos1+1);
-                               std::string x=line.substr(pos1+1,pos2-pos1-1);
-                               bl=atof(x.c_str());     
-                               bluevect.push_back(bl);
+               {
+                       item = new HistogramDialogComboBoxItem();
+               }else if((int)(line.find("<greyValue>"))!=-1) {
+                       int pos1=line.find(">");
+                       int pos2=line.find("<",pos1+1);
+                       std::string x=line.substr(pos1+1,pos2-pos1-1);
+                       gvtransfer=atof(x.c_str());                             
+                       greyvecttransfunct.push_back(gvtransfer);
+               }else if((int)(line.find("<intensity>"))!=-1) {
+                       int pos1=line.find(">");
+                       int pos2=line.find("<",pos1+1);
+                       std::string x=line.substr(pos1+1,pos2-pos1-1);
+                       intensity=atof(x.c_str());                                      
+                       value.push_back(intensity);
+               }
+               else if( (int)(line.find("<RGBgreyValue>"))!=-1)
+               {
+                       int pos1=line.find(">");
+                       int pos2=line.find("<",pos1+1);
+                       std::string x=line.substr(pos1+1,pos2-pos1-1);
+                       gv=atof(x.c_str());                             
+                       greyvect.push_back(gv);                         
+               }
+               else if( (int)(line.find("<red>"))!=-1)
+               {
+                       int pos1=line.find(">");
+                       int pos2=line.find("<",pos1+1);
+                       std::string x=line.substr(pos1+1,pos2-pos1-1);
+                       red=atof(x.c_str());
+                       redvect.push_back(red);                         
+               }
+               else if( (int)(line.find("<green>"))!=-1)
+               {
+                       int pos1=line.find(">");
+                       int pos2=line.find("<",pos1+1);
+                       std::string x=line.substr(pos1+1,pos2-pos1-1);
+                       gr=atof(x.c_str());
+                       greenvect.push_back(gr);
+               }
+               else if( (int)(line.find("<blue>"))!=-1 )
+               {
+                       int pos1=line.find(">");
+                       int pos2=line.find("<",pos1+1);
+                       std::string x=line.substr(pos1+1,pos2-pos1-1);
+                       bl=atof(x.c_str());     
+                       bluevect.push_back(bl);
                                
-                       }else if( (int)(line.find("</ComboBoxItem>"))!=-1 ){
+               }else if( (int)(line.find("</ComboBoxItem>"))!=-1 ) {
 
-                               item->SetColors(greyvect,redvect,greenvect,bluevect);
-                               item->SetTransferFunction(greyvecttransfunct,value);
-                               /*for(int i = 0; i < greyvecttransfunct.size();i++){
+                       item->SetColors(greyvect,redvect,greenvect,bluevect);
+                       item->SetTransferFunction(greyvecttransfunct,value);
+                       /*for(int i = 0; i < greyvecttransfunct.size();i++){
                                        std::cout<<"HistogramDialogComboBox::OnLoadComboBoxData("<<greyvecttransfunct[i]<<std::endl;
                                        std::cout<<value[i]<<std::endl;
-                               }
-                               for(int i = 0; i < greyvect.size();i++){
+                       }
+                       for(int i = 0; i < greyvect.size();i++){
                                        std::cout<<"HistogramDialogComboBox::OnLoadComboBoxData("<<greyvect[i]<<std::endl;
                                        std::cout<<redvect[i]<<std::endl;
                                        std::cout<<greenvect[i]<<std::endl;
                                        std::cout<<bluevect[i]<<std::endl;
-                               }*/
+                       }*/
                                
-                               itembitmaps.push_back(item);
-
-                               greyvecttransfunct.clear();
-                               value.clear();
-                               greyvect.clear();
-                               redvect.clear();
-                               greenvect.clear();
-                               bluevect.clear();
-                       }
-                       line.clear();
+                       itembitmaps.push_back(item);
+
+                       greyvecttransfunct.clear();
+                       value.clear();
+                       greyvect.clear();
+                       redvect.clear();
+                       greenvect.clear();
+                       bluevect.clear();
                }
-               file.close();                   
-               //std::cout<<itembitmaps.size()<<std::endl;
+               line.clear();
+       }
+       file.close();                   
+       //std::cout<<itembitmaps.size()<<std::endl;
      }         
 }
 
@@ -384,7 +401,7 @@ void HistogramDialogComboBox::OnLoadComboBoxData(std::vector<HistogramDialogComb
 **/
 void HistogramDialogComboBox::GetValuesPointsFunction(std::vector<double>& greylevel,std::vector<double>& value)
 {      
-       for(int i = 0; i < _greyvecttransfer.size();i++)              
+       for(int i = 0; i < _greyvecttransfer.size();i++) {              
                greylevel.push_back(_greyvecttransfer[i]*_maxgreyvalue);
                value.push_back(_value[i]);     
        }
@@ -399,7 +416,7 @@ void HistogramDialogComboBox::GetValuesColorPointsFunction(std::vector<double>&
                                                                std::vector<double>& green,
                                                                std::vector<double>& blue)
 {      
-       for(int i = 0; i < _greyvect.size();i++)              
+       for(int i = 0; i < _greyvect.size();i++) {              
                greylevel.push_back(_greyvect[i]*_maxgreyvalue);
                red.push_back(_redvect[i]);
                green.push_back(_greenvect[i]);