From: Eduardo DAVILA Date: Mon, 19 Dec 2016 14:02:06 +0000 (+0100) Subject: #3043 BBTK Bug New Normal - FilesFromDirectoryBox missing directories AND Refresh... X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?p=bbtk.git;a=commitdiff_plain;h=8654fac291feca76ace7256d3f38e92edfb35919 #3043 BBTK Bug New Normal - FilesFromDirectoryBox missing directories AND Refresh in wxComboBox --- diff --git a/packages/std/src/bbstdFilesFromDirectory.cxx b/packages/std/src/bbstdFilesFromDirectory.cxx index 6712c8c..7560fd8 100644 --- a/packages/std/src/bbstdFilesFromDirectory.cxx +++ b/packages/std/src/bbstdFilesFromDirectory.cxx @@ -139,7 +139,15 @@ int FilesFromDirectory::Explore(std::string const &dirpath, bool recursive) } // Type Lsast_directories numberOfFiles = numberOfFiles + tmpNumberOfFiles; - } // if + } // if recursive + if ( fileName != "." && fileName != ".." && !recursive ) + if ((bbGetInputType()==1) || (bbGetInputType()==2)) + { + std::string temp = dirName+fileName; + Filenames.push_back(temp); + numberOfFiles++; + } // Type All_directories + }// fileName && !recursive } else { // std::string temp = "\"" +dirName+fileName + "\""; std::string temp = dirName+fileName; @@ -232,7 +240,7 @@ int FilesFromDirectory::Explore(std::string const &dirpath, bool recursive) } // Type files } // d_name } else if ( S_ISDIR(buf.st_mode) ) { //directory? - if ( d->d_name[0] != '.' && recursive ) //we also skip hidden files + if ( (d->d_name[0]!='.') && recursive ) //we also skip hidden files { if (bbGetInputType()==1) { @@ -247,7 +255,16 @@ int FilesFromDirectory::Explore(std::string const &dirpath, bool recursive) numberOfFiles++; } // Type Lsast_directories numberOfFiles = numberOfFiles+tmpNumberOfFiles; - } // d_name + }// d_name && recursive + if ( (d->d_name[0]!='.') && !recursive ) { //we also skip hidden files + if ((bbGetInputType()==1) || (bbGetInputType()==2)) + { + Filenames.push_back(fileName); + numberOfFiles++; + } // Type All_directories + + }// d_name && !recursive + } else { //gdcmErrorMacro( "Unexpected error" ); return -1; diff --git a/packages/wx/src/bbwxComboBox.cxx b/packages/wx/src/bbwxComboBox.cxx index e270639..051cfea 100644 --- a/packages/wx/src/bbwxComboBox.cxx +++ b/packages/wx/src/bbwxComboBox.cxx @@ -20,22 +20,20 @@ namespace bbwx { public: ComboBoxWidget( ComboBox* box, wxWindow *parent, - int iSelection, - std::string title, - std::vector< std::string > lstIn, - int typeForm ); - + int iSelection, + std::string title, + std::vector< std::string > lstIn, + int typeForm ); ~ComboBoxWidget(); - + void OnComboBox(int iSelection); void OnComboBox(wxEvent& event); void FillItems( int iSelection, std::vector< std::string > lstIn); - private: - int mTypeForm; + int mTypeForm; ComboBox *mBox; - wxListBox *wxlistbox; - wxChoice *wxchoice; + wxListBox *wxlistbox; + wxChoice *wxchoice; }; @@ -56,12 +54,10 @@ namespace bbwx mBox(box), mTypeForm(typeForm) { - wxPanel *panel = this; + wxPanel *panel = this; wxlistbox = NULL; - wxchoice = NULL; - int i; - - + wxchoice = NULL; + int i; //--------------------------------------------------------------------- // 2) Insertion of the components in the window @@ -74,8 +70,7 @@ namespace bbwx } sizer->AddGrowableCol(0); panel->SetSizer(sizer); - - + //--------------------------------------------------------------------- // 1) Creation de wxChoise widget @@ -102,11 +97,8 @@ namespace bbwx wxchoice->SetSelection(iSelection); sizer->Add( wxchoice,1,wxGROW ); } - - // panel->SetAutoLayout(true); // panel->Layout(); - } //------------------------------------------------------------------------- @@ -114,6 +106,17 @@ namespace bbwx { } + + //-------------------------------------------------------------------------- + void ComboBoxWidget::OnComboBox(int iSelection) + { + mBox->bbSetInputSelection( iSelection ); + mBox->bbSetOutputOut( iSelection ); + mBox->bbSetOutputOutString( bbtk::wx2std( wxchoice->GetString(iSelection) ) ); + mBox->bbSignalOutputModification("Out"); + mBox->bbSignalOutputModification("OutString"); + } + //-------------------------------------------------------------------------- void ComboBoxWidget::OnComboBox(wxEvent& event) { @@ -124,14 +127,8 @@ namespace bbwx } else { iSelection = wxchoice->GetSelection(); } - - mBox->bbSetInputSelection( iSelection ); - mBox->bbSetOutputOut( iSelection ); - mBox->bbSetOutputOutString( bbtk::wx2std( wxchoice->GetString(iSelection) ) ); - mBox->bbSignalOutputModification("Out"); - mBox->bbSignalOutputModification("OutString"); + OnComboBox(iSelection); } - //-------------------------------------------------------------------------- void ComboBoxWidget::FillItems( int iSelection, @@ -166,8 +163,16 @@ BBTK_BLACK_BOX_IMPLEMENTATION(ComboBox,bbtk::WxBlackBox); //===== void ComboBox::Process() { - ComboBoxWidget *w = (ComboBoxWidget*)bbGetOutputWidget(); - w->FillItems( bbGetInputSelection(),bbGetInputIn() ); + int iSelection = bbGetInputSelection(); + if (bbGetInputSelection() >= bbGetInputIn().size()) { iSelection=bbGetInputIn().size()-1; } + ComboBoxWidget *w = (ComboBoxWidget*)bbGetOutputWidget(); + w->FillItems( iSelection, bbGetInputIn() ); + bbSetInputSelection( iSelection ); + bbSetOutputOut( iSelection ); + bbSetOutputOutString( bbGetInputIn()[ iSelection ] ); +// bbSignalOutputModification("Out"); +// bbSignalOutputModification("OutString"); + } //===== @@ -182,7 +187,7 @@ void ComboBox::CreateWidget(wxWindow* parent) ComboBoxWidget *w = new ComboBoxWidget( this, - parent, + parent, bbGetInputSelection() , bbGetInputTitle(), bbGetInputIn(),