From: Eduardo DAVILA Date: Mon, 27 Nov 2017 11:50:03 +0000 (+0100) Subject: 3152 BBTK BugN ew Normal - ShareMemory, ComboBox->list X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=f9574f4d8fb212474d38c304002a493051c7b579;p=bbtk.git 3152 BBTK BugN ew Normal - ShareMemory, ComboBox->list --- diff --git a/packages/std/src/bbstdSharedMemory.cxx b/packages/std/src/bbstdSharedMemory.cxx index 75aea87..5dfd30a 100644 --- a/packages/std/src/bbstdSharedMemory.cxx +++ b/packages/std/src/bbstdSharedMemory.cxx @@ -70,7 +70,8 @@ namespace bbstd void SharedMemory::bbUserSetDefaultValues() { - mCanSet = true; + mCanSet = true; + firsttime = true; } void SharedMemory::bbUserInitializeProcessing() { @@ -81,6 +82,11 @@ namespace bbstd void SharedMemory::DoProcess() { mCanSet = true; + if (firsttime==true) + { + firsttime = false; + bbSetOutputOut( bbGetInputIn() ); + } } BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,SharedMemory); diff --git a/packages/std/src/bbstdSharedMemory.h b/packages/std/src/bbstdSharedMemory.h index a981f28..7e8c5be 100644 --- a/packages/std/src/bbstdSharedMemory.h +++ b/packages/std/src/bbstdSharedMemory.h @@ -57,7 +57,10 @@ public: \ public bbtk::AtomicBlackBox { BBTK_BLACK_BOX_INTERFACE(SharedMemory,bbtk::AtomicBlackBox); + +// BBTK_DECLARE_INPUT(In,bbtk::Data); BBTK_MB_DECLARE_INPUT(In,bbtk::Data); + BBTK_MB_DECLARE_INPUT(In1,bbtk::Data); BBTK_MB_DECLARE_INPUT(In2,bbtk::Data); BBTK_MB_DECLARE_INPUT(In3,bbtk::Data); @@ -75,6 +78,7 @@ public: \ virtual void bbSetStatusAndPropagate(bbtk::BlackBoxInputConnector* c, bbtk::IOStatus s); bool mCanSet; + bool firsttime; }; //================================================================== diff --git a/packages/wx/src/bbwxComboBox.cxx b/packages/wx/src/bbwxComboBox.cxx index 5b8ab45..b11c558 100644 --- a/packages/wx/src/bbwxComboBox.cxx +++ b/packages/wx/src/bbwxComboBox.cxx @@ -23,7 +23,8 @@ namespace bbwx int iSelection, std::string title, std::vector< std::string > lstIn, - int typeForm ); + int typeForm, + int sizeX, int sizeY ); ~ComboBoxWidget(); void OnComboBoxSelection(int iSelection); void OnComboBox(wxEvent& event); @@ -32,8 +33,7 @@ namespace bbwx private: int mTypeForm; ComboBox *mBox; - wxListBox *wxlistbox; - wxChoice *wxchoice; + wxItemContainer* itemcontainer; }; @@ -44,19 +44,21 @@ namespace bbwx //------------------------------------------------------------------------- ComboBoxWidget::ComboBoxWidget( ComboBox* box, - wxWindow *parent, - int iSelection, - std::string title, - std::vector< std::string > lstIn, - int typeForm) + wxWindow *parent, + int iSelection, + std::string title, + std::vector< std::string > lstIn, + int typeForm, + int sizeX, + int sizeY + ) : wxPanel( parent, -1) , mBox(box), mTypeForm(typeForm) { wxPanel *panel = this; - wxlistbox = NULL; - wxchoice = NULL; + itemcontainer = NULL; int i; //--------------------------------------------------------------------- @@ -70,35 +72,26 @@ namespace bbwx } sizer->AddGrowableCol(0); panel->SetSizer(sizer); - //--------------------------------------------------------------------- - // 1) Creation de wxChoise widget - - if (mTypeForm==1) - { - - wxlistbox = new wxListBox ( panel , -1 ); - Connect( wxlistbox->GetId(), wxEVT_COMMAND_CHOICE_SELECTED, (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&))&ComboBoxWidget::OnComboBox ); - for (i=0;iAppend( bbtk::std2wx( lstIn[i] ) ); - } // for i - wxlistbox->SetSelection(iSelection); - sizer->Add( wxlistbox,1,wxGROW ); - - } else { - - wxchoice = new wxChoice ( panel , -1 ); - Connect( wxchoice->GetId(), wxEVT_COMMAND_CHOICE_SELECTED, (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&))&ComboBoxWidget::OnComboBox ); - for (i=0;iAppend( bbtk::std2wx( lstIn[i] ) ); - } // for i - wxchoice->SetSelection(iSelection); - sizer->Add( wxchoice,1,wxGROW ); - } -// panel->SetAutoLayout(true); -// panel->Layout(); + if (mTypeForm==1) + { + wxListBox *wxlistbox = new wxListBox ( panel , -1 , wxDefaultPosition,wxSize(sizeX,sizeY),0, NULL, wxLB_SINGLE ); + itemcontainer=wxlistbox; + sizer->Add( wxlistbox,1,wxEXPAND ); + Connect( wxlistbox->GetId(), + wxEVT_COMMAND_LISTBOX_SELECTED, (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&))&ComboBoxWidget::OnComboBox ); + } else if (mTypeForm==0) { + wxChoice *wxchoice = new wxChoice ( panel , -1 ); + itemcontainer=wxchoice; + sizer->Add( wxchoice,1,wxGROW ); + Connect( wxchoice->GetId(), + wxEVT_COMMAND_CHOICE_SELECTED, (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&))&ComboBoxWidget::OnComboBox ); + } + for (i=0;iAppend( bbtk::std2wx( lstIn[i] ) ); + } // for i + itemcontainer->SetSelection(iSelection); } //------------------------------------------------------------------------- @@ -110,50 +103,31 @@ namespace bbwx //-------------------------------------------------------------------------- void ComboBoxWidget::OnComboBoxSelection(int iSelection) { - mBox->bbSetInputSelection( iSelection ); - mBox->bbSetOutputOut( iSelection ); - mBox->bbSetOutputOutString( bbtk::wx2std( wxchoice->GetString(iSelection) ) ); - mBox->bbSignalOutputModification("Out"); - mBox->bbSignalOutputModification("OutString"); + if (iSelection>=0) + { + mBox->bbSetInputSelection( iSelection ); + mBox->bbSetOutputOut( iSelection ); + mBox->bbSetOutputOutString( bbtk::wx2std( itemcontainer->GetString(iSelection) ) ); + mBox->bbSignalOutputModification("Out"); + mBox->bbSignalOutputModification("OutString"); + } // if iSelection } //-------------------------------------------------------------------------- void ComboBoxWidget::OnComboBox(wxEvent& event) { - int iSelection; - if (mTypeForm==1) - { - iSelection = wxlistbox->GetSelection(); - } else { - iSelection = wxchoice->GetSelection(); - } - OnComboBoxSelection(iSelection); + OnComboBoxSelection( itemcontainer->GetSelection() ); } //-------------------------------------------------------------------------- - void ComboBoxWidget::FillItems( - int iSelection, - std::vector< std::string > lstIn - ) + void ComboBoxWidget::FillItems( int iSelection, std::vector< std::string > lstIn ) { int i; - if (mTypeForm==1) - { - wxlistbox->Clear(); - - for (i=0;iAppend( bbtk::std2wx( lstIn[i] ) ); - } // for i - - wxlistbox->SetSelection(iSelection); - } else { - wxchoice->Clear(); - for (i=0;iAppend( bbtk::std2wx( lstIn[i] ) ); - } // for i - wxchoice->SetSelection(iSelection); - } // if + itemcontainer->Clear(); + for (i=0;iAppend( bbtk::std2wx( lstIn[i] ) ); + } // for i + itemcontainer->SetSelection(iSelection); } BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,ComboBox) @@ -175,8 +149,6 @@ void ComboBox::Process() { bbSetOutputOutString( bbGetInputIn()[ iSelection ] ); } -// bbSignalOutputModification("Out"); -// bbSignalOutputModification("OutString"); } //===== @@ -184,24 +156,17 @@ void ComboBox::Process() //===== void ComboBox::CreateWidget(wxWindow* parent) { - -// bbSetOutputWidget( new wxStaticText ( parent , -1 , _T("") ) ); -// bbSetOutputWidget( new wxComboBox ( parent , -1 , _T("ups") ) ); -// bbSetOutputWidget( new wxChoice ( parent , -1 ) ); - ComboBoxWidget *w = new ComboBoxWidget( this, parent, bbGetInputSelection() , bbGetInputTitle(), bbGetInputIn(), - bbGetInputForm() ); - + bbGetInputForm(), + bbGetInputWinWidth(), bbGetInputWinHeight() ); bbSetOutputOut( bbGetInputSelection() ); bbSetOutputOutString( bbGetInputIn()[ bbGetInputSelection() ] ); bbSetOutputWidget( w ); - - } //===== // 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) @@ -211,6 +176,8 @@ void ComboBox::bbUserSetDefaultValues() bbSetInputSelection(0); bbSetInputTitle(""); bbSetInputForm(0); + bbSetInputWinWidth(100); + bbSetInputWinHeight(200); } //===== // 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)