]> Creatis software - bbtk.git/commitdiff
#3043 BBTK Bug New Normal - FilesFromDirectoryBox missing directories AND Refresh...
authorEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Mon, 19 Dec 2016 14:02:06 +0000 (15:02 +0100)
committerEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Mon, 19 Dec 2016 14:02:06 +0000 (15:02 +0100)
packages/std/src/bbstdFilesFromDirectory.cxx
packages/wx/src/bbwxComboBox.cxx

index 6712c8cca4230ee8a6008098204ff4d8d099d93c..7560fd896335b377d8a6803593fc3d2304aee2a9 100644 (file)
@@ -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;
index e270639d7a97aa118eccdb02d46461f9590fde93..051cfea7f811e319419dd19f680f106263040d0f 100644 (file)
@@ -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(),