]> Creatis software - bbtk.git/commitdiff
#3465 Spin in combobox Box and FilterString (find strings)
authorEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Wed, 16 Jun 2021 07:12:52 +0000 (09:12 +0200)
committerEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Wed, 16 Jun 2021 07:12:52 +0000 (09:12 +0200)
packages/std/src/bbstdVectorFilterString.cxx
packages/std/src/bbstdVectorFilterString.h
packages/wx/src/bbwxComboBox.cxx
packages/wx/src/bbwxComboBox.h

index 7b5da8bb009aca6816f382b410a884c025785b5f..1973e7be5fbeddf50e10d6d2742c7a4232e3fc6f 100644 (file)
@@ -31,6 +31,51 @@ void VectorFilterString::ConnectionRepetitions( std::vector<std::string> vIn,std
        vOut->push_back(std::to_string(acum));
 }
 
+void VectorFilterString::FilterByFindinIn0()
+{
+       std::vector<std::string> vOut0;
+       std::vector<std::string> vOut1;
+       std::vector<std::string> vOut2;
+       std::vector<std::string> vOut3;
+       std::vector<std::string> vOut4;
+       std::vector<std::string> vOut5;
+       std::vector<std::string> vOut6;
+       std::vector<std::string> vOut7;
+       std::vector<std::string> vOut8;
+       std::vector<std::string> vOut9;
+
+       int i,size = bbGetInputIn0().size();
+       int pos;
+       for (i=0; i<size; i++)
+       {
+               pos=bbGetInputIn0()[i].find( bbGetInputsk1());
+               if (  pos  >= 0)
+               {
+                       vOut0.push_back( bbGetInputIn0()[i] );
+                       if ( i < bbGetInputIn1().size() ) { vOut1.push_back( bbGetInputIn1()[i] ); }
+                       if ( i < bbGetInputIn2().size() ) { vOut2.push_back( bbGetInputIn2()[i] ); }
+                       if ( i < bbGetInputIn3().size() ) { vOut3.push_back( bbGetInputIn3()[i] ); }
+                       if ( i < bbGetInputIn4().size() ) { vOut4.push_back( bbGetInputIn4()[i] ); }
+                       if ( i < bbGetInputIn5().size() ) { vOut5.push_back( bbGetInputIn5()[i] ); }
+                       if ( i < bbGetInputIn6().size() ) { vOut6.push_back( bbGetInputIn6()[i] ); }
+                       if ( i < bbGetInputIn7().size() ) { vOut7.push_back( bbGetInputIn7()[i] ); }
+                       if ( i < bbGetInputIn8().size() ) { vOut8.push_back( bbGetInputIn8()[i] ); }
+                       if ( i < bbGetInputIn9().size() ) { vOut9.push_back( bbGetInputIn9()[i] ); }
+               } // if pos
+       } // for i
+       
+       bbSetOutputOut0( vOut0 );
+       bbSetOutputOut1( vOut1 );
+       bbSetOutputOut2( vOut2 );
+       bbSetOutputOut3( vOut3 );
+       bbSetOutputOut4( vOut4 );
+       bbSetOutputOut5( vOut5 );
+       bbSetOutputOut6( vOut6 );
+       bbSetOutputOut7( vOut7 );
+       bbSetOutputOut8( vOut8 );
+       bbSetOutputOut9( vOut9 );
+       
+}
 
 
 void VectorFilterString::Process()
@@ -86,6 +131,11 @@ void VectorFilterString::Process()
        }
 
 
+       if (bbGetInputType()==2) 
+       {
+               FilterByFindinIn0();
+       }
+
 }
 //===== 
 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
index 0856f6607a15cc1b4b09b5d47059a74c93e67129..4bfe5afb9fb3d3a726c40760875f26fcac9daeda 100644 (file)
@@ -47,6 +47,8 @@ class bbstd_EXPORT VectorFilterString
   void Process();
 
 void ConnectionRepetitions( std::vector<std::string> vIn,std::vector<std::string> *vOut );
+void FilterByFindinIn0();
+
 
 //===== 
 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
@@ -69,7 +71,7 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(VectorFilterString,bbtk::AtomicBlackBox);
   BBTK_INPUT(VectorFilterString,In7,"Input vector",std::vector<std::string>,"");
   BBTK_INPUT(VectorFilterString,In8,"Input vector",std::vector<std::string>,"");
   BBTK_INPUT(VectorFilterString,In9,"Input vector",std::vector<std::string>,"");
-  BBTK_INPUT(VectorFilterString,Type,"(Default 0)  0:count connected repetitions, 1:CleaningPointsConnectTwoMesh sk1 criterium",int,"");
+  BBTK_INPUT(VectorFilterString,Type,"(Default 0)  0:count connected repetitions, 1:CleaningPointsConnectTwoMesh sk1 criterium, 2: Select lines contain sk1 in In0  (the other intputs In1..In9 are afected)",int,"");
   BBTK_INPUT(VectorFilterString,sk1,"constant 1",std::string,"");
   BBTK_INPUT(VectorFilterString,sk2,"constant 2",std::string,"");
 
index 411d8db04b3d06e309feec6899e6d78cf9b79861..086708b92fa2fa554b0f160fc006ff2418a16960 100644 (file)
@@ -12,6 +12,8 @@
 #include <wx/control.h>
 #include <wx/listbox.h>
 
+#include <wx/spinbutt.h>
+
 namespace bbwx
 {
   //--------------------------------------------------------------------------
@@ -31,10 +33,14 @@ namespace bbwx
        void FillItems( int iSelection, std::vector< std::string > lstIn);
     void VerifyDeselect(int iSelection);
 
+    void OnSpinCtrlClick(wxCommandEvent& event);
+
+
   private:
     int                        mTypeForm;
     ComboBox           *mBox;
-       wxItemContainer* itemcontainer;
+       wxItemContainer *itemcontainer;
+       wxSpinButton    *mwxspinbutton;
   };
   
 
@@ -58,6 +64,7 @@ namespace bbwx
     mBox(box),
     mTypeForm(typeForm)
   {
+       mwxspinbutton                   = NULL;
        itemcontainer                   = NULL;
        wxPanel                 *panel  = this;
        int                     i;
@@ -65,7 +72,7 @@ namespace bbwx
     // 2) Insertion of the components in the window
     
     // We use a FlexGridSizer
-    wxFlexGridSizer *sizer     = new wxFlexGridSizer(1);
+    wxFlexGridSizer *sizer     = new wxFlexGridSizer(2);
     if (title!="")
     {
           sizer->Add( new wxStaticText(panel,-1,  bbtk::std2wx(title) ) ); 
@@ -77,7 +84,7 @@ namespace bbwx
                itemcontainer=wxlistbox;
                sizer->Add( wxlistbox,1,wxEXPAND ); 
                Connect( wxlistbox->GetId(), 
-                 wxEVT_COMMAND_LISTBOX_SELECTED, (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&))&ComboBoxWidget::OnComboBox ); 
+                 wxEVT_COMMAND_LISTBOX_SELECTED, (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&))&ComboBoxWidget::OnComboBox );                  
        } else if (mTypeForm==0) {
                wxChoice *wxchoice = new wxChoice ( panel , -1, wxDefaultPosition,wxSize(sizeX,sizeY));
                itemcontainer=wxchoice;
@@ -85,11 +92,21 @@ namespace bbwx
                Connect( wxchoice->GetId(), 
                  wxEVT_COMMAND_CHOICE_SELECTED, (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&))&ComboBoxWidget::OnComboBox ); 
        }
-    sizer->AddGrowableCol(0);
-    panel->SetSizer(sizer);
        
+       if (mBox->bbGetInputWithSpinButton()==true)
+       {
+               mwxspinbutton = new wxSpinButton( panel, -1 );    
+               Connect( mwxspinbutton->GetId(), 
+                        wxEVT_SPIN, 
+                        (wxObjectEventFunction) 
+                        (void (wxPanel::*)(wxScrollEvent&))
+                        &ComboBoxWidget::OnSpinCtrlClick);
+  
+               sizer->Add( mwxspinbutton,1,wxEXPAND ); 
+       }
 
-
+    sizer->AddGrowableCol(0);
+    panel->SetSizer(sizer);
        FillItems( iSelection,lstIn );
        
 //     for (i=0;i<lstIn.size(); i++)
@@ -147,9 +164,39 @@ namespace bbwx
 //--------------------------------------------------------------------------
 void ComboBoxWidget::OnComboBox(wxEvent& event)
 {
-       OnComboBoxSelection( itemcontainer->GetSelection() );
+       int iSelection = itemcontainer->GetSelection();
+       OnComboBoxSelection( iSelection );
+       if (mBox->bbGetInputWithSpinButton()==true)
+       {
+               mwxspinbutton->SetValue( iSelection );
+       }
+
+}
+
+//--------------------------------------------------------------------------
+void ComboBoxWidget::OnSpinCtrlClick(wxCommandEvent& event)
+{
+       int iSelection = mwxspinbutton->GetValue();
+       printf("EED ComboBoxWidget::OnSpinCtrlClick %d\n", iSelection );
+       itemcontainer->SetSelection(iSelection);
+       OnComboBoxSelection( iSelection );
+
+/*
+       if (mBox->bbGetInputType()==0)
+       {
+         mBox->bbSetOutputOut( mwxSpinCtrl->GetValue() );
+       } else {
+         mBox->bbSetOutputOut( mwxSpinButton->GetValue() );
+       }// if Type
+
+         // and signal that the output has changed
+         //if(_reactiveOnKeyStroke==1){
+         mBox->bbSignalOutputModification(std::string("Out"));
+         //}
+*/       
 }
 
+
 //--------------------------------------------------------------------------
 void ComboBoxWidget::FillItems( int iSelection, std::vector< std::string > lstIn )
 {
@@ -183,7 +230,16 @@ void ComboBoxWidget::FillItems( int iSelection, std::vector< std::string > lstIn
        {
                itemcontainer->Append(  bbtk::std2wx( lstIn[i] )  ); 
        } // for i
-       if (iSelection>=0) itemcontainer->SetSelection(iSelection);
+       if (iSelection>=0)
+       { 
+               itemcontainer->SetSelection(iSelection); 
+               if (mBox->bbGetInputWithSpinButton()==true)
+               {
+                   mwxspinbutton->SetRange( 0,size-1 );
+                       mwxspinbutton->SetValue( iSelection );
+               }
+
+       } // iSelection
 
        if (mTypeForm==0) 
        { 
@@ -245,6 +301,7 @@ void ComboBox::bbUserSetDefaultValues()
        bbSetInputWinWidth(10);
        bbSetInputWinHeight(45);
        bbSetInputDeselect(false);
+       bbSetInputWithSpinButton(false);
 }
 //===== 
 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
index 776a89f6a66bcd9bfdf3077e12004af2f94da249..de0b439ca8d61014b182ad7f259fe1a972c71158 100644 (file)
@@ -23,6 +23,7 @@ class bbwx_EXPORT ComboBox
   BBTK_DECLARE_INPUT(In,std::vector< std::string >);
   BBTK_DECLARE_INPUT(Form, int );
   BBTK_DECLARE_INPUT(Deselect, bool );
+  BBTK_DECLARE_INPUT(WithSpinButton, bool );
 
   BBTK_DECLARE_OUTPUT(Out, int );
   BBTK_DECLARE_OUTPUT(OutString, std::string );
@@ -47,6 +48,7 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(ComboBox,bbtk::WxBlackBox);
        BBTK_INPUT(ComboBox,In,"Vector of strings",std::vector< std::string >,"");
        BBTK_INPUT(ComboBox,Form,"0 Combobox, 1 List  (default 0)",int,"");
        BBTK_INPUT(ComboBox,Deselect,"(default false) Just for List form",bool,"");
+       BBTK_INPUT(ComboBox,WithSpinButton,"(default false) With spin button",bool,"");
 
     BBTK_OUTPUT(ComboBox,Out,"i Item selected",int,"");
     BBTK_OUTPUT(ComboBox,OutString,"string Item selected",std::string,"");