From aaa8070f20da168c0ef2f8aa94c30015386cd100 Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Thu, 16 Apr 2020 10:35:03 +0200 Subject: [PATCH] #3385 BBTK Bug New Normal - box FilesFromDirectory CreateImage InvertCrop ComboBox LayerTab --- kernel/src/bbtkBlackBox.cxx | 12 +- packages/std/src/bbstdFilesFromDirectory.cxx | 27 ++- packages/vtk/src/bbvtkCreateImage.cxx | 177 ++++++++++--------- packages/vtk/src/bbvtkInversCrop.cxx | 26 ++- packages/wx/src/bbwxComboBox.cxx | 42 ++--- packages/wx/src/bbwxComboBox.h | 2 + packages/wx/src/bbwxLayoutTab.cxx | 8 +- 7 files changed, 145 insertions(+), 149 deletions(-) diff --git a/kernel/src/bbtkBlackBox.cxx b/kernel/src/bbtkBlackBox.cxx index dbab39b..4b000f0 100644 --- a/kernel/src/bbtkBlackBox.cxx +++ b/kernel/src/bbtkBlackBox.cxx @@ -183,13 +183,11 @@ namespace bbtk std::string BlackBox::bbGetNameWithParent() const { if (bbmParent.lock()) - { - return bbmParent.lock()->bbGetNameWithParent() + ":" + bbmName; - } - else - { - return bbmName; - } + { + return bbmParent.lock()->bbGetNameWithParent() + ":" + bbmName; + } else { + return bbmName; + } } //========================================================================= diff --git a/packages/std/src/bbstdFilesFromDirectory.cxx b/packages/std/src/bbstdFilesFromDirectory.cxx index 3a694d2..387b5ad 100644 --- a/packages/std/src/bbstdFilesFromDirectory.cxx +++ b/packages/std/src/bbstdFilesFromDirectory.cxx @@ -293,24 +293,27 @@ if (recursiveLevel>=0){ void FilesFromDirectory::CleanFilenames( std::string basePath ) { std::string tmpString; - int i,ii,sizeFilenames = Filenames.size(); - int j,sizeFileEnd = bbGetInputFileEnd().size(); - + int i,ii,sizeFilenames = Filenames.size(); + int j,sizeFileEnd = bbGetInputFileEnd().size(); int okEraseElement; - + int posStr; //Selecting just the files in the FileEnd List if (bbGetInputFileEnd().size()!=0) { for (i=sizeFilenames-1; i>=0; i--) { - okEraseElement=0; + okEraseElement = 0; for (j=0; j=0) { - okEraseElement++; - } // if FileEnd + std::string tmp=Filenames[i].substr( posStr ) ; + if (bbGetInputFileEnd()[j].compare( tmp )==0 ) + { + okEraseElement++; + } // if FileEnd + }// if posStr } // for j if (okEraseElement==0) @@ -319,14 +322,11 @@ void FilesFromDirectory::CleanFilenames( std::string basePath ) } } // for i } // if FileEnd !=0 - sizeFilenames = Filenames.size(); - // Cleanning paths with spaces for (i=0; iDelete();} - imageoutput = vtkImageData::New(); - imageoutput->Initialize(); - imageoutput->SetSpacing( spc ); - imageoutput->SetDimensions( dim[0], dim[1], dim[2] ); - -//EED 2017-01-01 Migration VTK7 -#if (VTK_MAJOR_VERSION <= 5) - imageoutput->SetScalarType( outputformat ); - imageoutput->AllocateScalars(); -#endif -#if (VTK_MAJOR_VERSION >= 6) - imageoutput->AllocateScalars( outputformat,1 ); -#endif - - int i,j,k; - long sizeBlock; + dim[0] = bbGetInputDimensions()[0]; + dim[1] = bbGetInputDimensions()[1]; + dim[2] = bbGetInputDimensions()[2]; - for (i=0; iSetScalarComponentFromDouble(i,0,0, 0, bbGetInputInitialValue() ); - } // for i - - sizeBlock= dim[0] * imageoutput->GetScalarSize(); - for (j=1; jGetScalarPointer(0,j,0), imageoutput->GetScalarPointer() , sizeBlock ); - } // for j + imageoutput->Delete(); + imageoutput = NULL; + } // if imageoutput - sizeBlock= dim[0] * dim[1] * imageoutput->GetScalarSize(); - for (k=0; kGetScalarPointer(0,0,k) ,imageoutput->GetScalarPointer() , sizeBlock ); - } // for k - - -//EED 2017-01-01 Migration VTK7 -#if (VTK_MAJOR_VERSION <= 5) - imageoutput->Update(); -#endif -#if (VTK_MAJOR_VERSION >= 6) - // .. -#endif + double spc[3]; + int outputformat = VTK_UNSIGNED_SHORT; + spc[0] = bbGetInputSpacing()[0]; + spc[1] = bbGetInputSpacing()[1]; + spc[2] = bbGetInputSpacing()[2]; + if (bbGetInputOutputFormat()=="VTK_BIT") outputformat = VTK_BIT; // 1 + else if (bbGetInputOutputFormat()=="VTK_CHAR") outputformat = VTK_CHAR; // 2 + else if (bbGetInputOutputFormat()=="MET_CHAR") outputformat = VTK_CHAR; // 2 + else if (bbGetInputOutputFormat()=="VTK_SIGNED_CHAR") outputformat = VTK_SIGNED_CHAR; // 15 + else if (bbGetInputOutputFormat()=="MET_UCHAR") outputformat = VTK_UNSIGNED_CHAR; // 3 + else if (bbGetInputOutputFormat()=="VTK_UNSIGNED_CHAR") outputformat = VTK_UNSIGNED_CHAR; // 3 + else if (bbGetInputOutputFormat()=="VTK_SHORT") outputformat = VTK_SHORT; // 4 + else if (bbGetInputOutputFormat()=="MET_SHORT") outputformat = VTK_SHORT; // 4 + else if (bbGetInputOutputFormat()=="VTK_UNSIGNED_SHORT") outputformat = VTK_UNSIGNED_SHORT; // 5 + else if (bbGetInputOutputFormat()=="MET_USHORT") outputformat = VTK_UNSIGNED_SHORT; // 5 + else if (bbGetInputOutputFormat()=="VTK_INT") outputformat = VTK_INT; // 6 + else if (bbGetInputOutputFormat()=="MET_INT") outputformat = VTK_INT; // 6 + else if (bbGetInputOutputFormat()=="VTK_UNSIGNED_INT") outputformat = VTK_UNSIGNED_INT; // 7 + else if (bbGetInputOutputFormat()=="MEY_UINT") outputformat = VTK_UNSIGNED_INT; // 7 + else if (bbGetInputOutputFormat()=="VTK_LONG") outputformat = VTK_LONG; // 8 + else if (bbGetInputOutputFormat()=="MET_LONG") outputformat = VTK_LONG; // 8 + else if (bbGetInputOutputFormat()=="VTK_UNSIGNED_LONG") outputformat = VTK_UNSIGNED_LONG; // 9 + else if (bbGetInputOutputFormat()=="MET_ULONG") outputformat = VTK_UNSIGNED_LONG; // 9 + else if (bbGetInputOutputFormat()=="VTK_FLOAT") outputformat = VTK_FLOAT; // 10 + else if (bbGetInputOutputFormat()=="MET_FLOAT") outputformat = VTK_FLOAT; // 10 + else if (bbGetInputOutputFormat()=="VTK_DOUBLE") outputformat = VTK_DOUBLE; // 11 + else if (bbGetInputOutputFormat()=="MET_DOUBLE") outputformat = VTK_DOUBLE; // 11 + + if ((dim[0]<=0)||(dim[1]<=0)||(dim[2]<=0)) + { + dim[0]=1; + dim[1]=1; + dim[2]=1; + } + if ((spc[0]<=0)||(spc[1]<=0)||(spc[2]<=0)) + { + spc[0]=1; + spc[1]=1; + spc[2]=1; + } + imageoutput = vtkImageData::New(); + imageoutput->Initialize(); + imageoutput->SetSpacing( spc ); + imageoutput->SetDimensions( dim[0], dim[1], dim[2] ); + + //EED 2017-01-01 Migration VTK7 + #if (VTK_MAJOR_VERSION <= 5) + imageoutput->SetScalarType( outputformat ); + imageoutput->AllocateScalars(); + #endif + #if (VTK_MAJOR_VERSION >= 6) + imageoutput->AllocateScalars( outputformat,1 ); + #endif + + int i,j,k; + long sizeBlock; + + for (i=0; iSetScalarComponentFromDouble(i,0,0, 0, bbGetInputInitialValue() ); + } // for i + + sizeBlock= dim[0] * imageoutput->GetScalarSize(); + for (j=1; jGetScalarPointer(0,j,0), imageoutput->GetScalarPointer() , sizeBlock ); + } // for j + + sizeBlock= dim[0] * dim[1] * imageoutput->GetScalarSize(); + for (k=0; kGetScalarPointer(0,0,k) ,imageoutput->GetScalarPointer() , sizeBlock ); + } // for k + + + //EED 2017-01-01 Migration VTK7 + #if (VTK_MAJOR_VERSION <= 5) + imageoutput->Update(); + #endif + #if (VTK_MAJOR_VERSION >= 6) + // .. + #endif + imageoutput->Modified(); + } // if dim = 0 - imageoutput->Modified(); bbSetOutputOut(imageoutput); } diff --git a/packages/vtk/src/bbvtkInversCrop.cxx b/packages/vtk/src/bbvtkInversCrop.cxx index 9e8c578..b43fa79 100644 --- a/packages/vtk/src/bbvtkInversCrop.cxx +++ b/packages/vtk/src/bbvtkInversCrop.cxx @@ -71,8 +71,6 @@ void InversCrop::Process() _imageoutput=bbGetInputImageFix(); } - - // Copy the Move Image int j,k; int px,py,pz; @@ -87,26 +85,24 @@ void InversCrop::Process() int dimMoveX = ext[1]-ext[0]+1; int dimMoveY = ext[3]-ext[2]+1; int dimMoveZ = ext[5]-ext[4]+1; - int spxM = 0; // start px MoveImage int sizeXM = 0; // sizeX MoveImage - px = bbGetInputOrigin()[0]; spxM = 0; if (px<0) { - spxM=px*(-1); - px=0; + spxM = px*(-1); + px = 0; } sizeXM = dimMoveX-spxM; if (px+sizeXM>=dim[0]) sizeXM=dim[0]-px; - sizeXM=sizeXM*bbGetInputImageFix()->GetScalarSize(); + sizeXM = sizeXM * bbGetInputImageFix()->GetScalarSize(); for (k=0; k=0) && (pz>=0) && (sizeXM>0) ) @@ -117,17 +113,15 @@ void InversCrop::Process() } // for j } // for k _imageoutput->Modified(); - } // If Image Fixe Move the same GetScalarType - else { + } else { // If Image Fixe Move the same GetScalarType printf ("ERROR: InversCrop both ImageFixe and ImageMove need the same format.\n"); printf (" type ImageFix:%d type ImageMove:%d\n", bbGetInputImageFix()->GetScalarType(), bbGetInputImageMove()->GetScalarType() ); } - } // If Image Fixe Move != NULL - else { - printf ("ERROR: InversCrop need ImageFixe and ImageMove to run.\n"); - } - bbSetOutputOut(_imageoutput); + } else { // If Image Fixe Move != NULL + printf ("ERROR: InversCrop need ImageFixe and ImageMove to run.\n"); + } + bbSetOutputOut(_imageoutput); } // if Active diff --git a/packages/wx/src/bbwxComboBox.cxx b/packages/wx/src/bbwxComboBox.cxx index c075b70..06ec591 100644 --- a/packages/wx/src/bbwxComboBox.cxx +++ b/packages/wx/src/bbwxComboBox.cxx @@ -58,10 +58,9 @@ namespace bbwx mBox(box), mTypeForm(typeForm) { - wxPanel *panel = this; itemcontainer = NULL; - int i; - + wxPanel *panel = this; + int i; //--------------------------------------------------------------------- // 2) Insertion of the components in the window @@ -83,7 +82,6 @@ namespace bbwx wxChoice *wxchoice = new wxChoice ( panel , -1, wxDefaultPosition,wxSize(sizeX,sizeY)); itemcontainer=wxchoice; sizer->Add( wxchoice,1,wxGROW ); - Connect( wxchoice->GetId(), wxEVT_COMMAND_CHOICE_SELECTED, (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&))&ComboBoxWidget::OnComboBox ); } @@ -123,9 +121,7 @@ namespace bbwx mBox->bbSetOutputOut( iSelection ); mBox->bbSetOutputOutString( bbtk::wx2std( itemcontainer->GetString(iSelection) ) ); mBox->bbSignalOutputModification(); - VerifyDeselect(iSelection); - if (mTypeForm==0) { wxChoice *wxchoise=(wxChoice *)itemcontainer; @@ -138,25 +134,27 @@ namespace bbwx } // if iSelection } - //-------------------------------------------------------------------------- - void ComboBoxWidget::OnComboBox(wxEvent& event) - { +//-------------------------------------------------------------------------- +void ComboBoxWidget::OnComboBox(wxEvent& event) +{ 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; + itemcontainer->Clear(); + for (i=0;iClear(); - for (i=0;iAppend( bbtk::std2wx( lstIn[i] ) ); - } // for i - if (iSelection>=0) itemcontainer->SetSelection(iSelection); - } + itemcontainer->Append( bbtk::std2wx( lstIn[i] ) ); + } // for i + if (iSelection>=0) itemcontainer->SetSelection(iSelection); +} BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,ComboBox) BBTK_BLACK_BOX_IMPLEMENTATION(ComboBox,bbtk::WxBlackBox); + //===== // 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) //===== @@ -174,7 +172,6 @@ void ComboBox::Process() { bbSetOutputOutString( bbGetInputIn()[ iSelection ] ); } // if iSelection - w->VerifyDeselect(iSelection); } //===== @@ -191,7 +188,10 @@ void ComboBox::CreateWidget(wxWindow* parent) bbGetInputForm(), bbGetInputWinWidth(), bbGetInputWinHeight() ); bbSetOutputOut( bbGetInputSelection() ); - bbSetOutputOutString( bbGetInputIn()[ bbGetInputSelection() ] ); + if (bbGetInputIn().size()> bbGetInputSelection() ) + { + bbSetOutputOutString( bbGetInputIn()[ bbGetInputSelection() ] ); + } // if InputIn size bbSetOutputWidget( w ); } //===== diff --git a/packages/wx/src/bbwxComboBox.h b/packages/wx/src/bbwxComboBox.h index 1f15781..776a89f 100644 --- a/packages/wx/src/bbwxComboBox.h +++ b/packages/wx/src/bbwxComboBox.h @@ -23,8 +23,10 @@ class bbwx_EXPORT ComboBox BBTK_DECLARE_INPUT(In,std::vector< std::string >); BBTK_DECLARE_INPUT(Form, int ); BBTK_DECLARE_INPUT(Deselect, bool ); + BBTK_DECLARE_OUTPUT(Out, int ); BBTK_DECLARE_OUTPUT(OutString, std::string ); + BBTK_PROCESS(Process); void Process(); BBTK_CREATE_WIDGET(CreateWidget); diff --git a/packages/wx/src/bbwxLayoutTab.cxx b/packages/wx/src/bbwxLayoutTab.cxx index a93b5d8..3655a77 100644 --- a/packages/wx/src/bbwxLayoutTab.cxx +++ b/packages/wx/src/bbwxLayoutTab.cxx @@ -82,9 +82,8 @@ namespace bbwx (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&)) &TabWidget::OnTabChange ); - wxFlexGridSizer *sizer = new wxFlexGridSizer(1); - sizer -> Add( mwxNotebook,1,wxGROW | wxALL,10 ); - sizer -> AddGrowableCol(0); + wxBoxSizer *sizer = new wxBoxSizer(wxHORIZONTAL); + sizer -> Add( mwxNotebook,1,wxGROW,0 ); panel -> SetSizer(sizer); panel -> SetAutoLayout(true); panel -> Layout(); @@ -96,7 +95,6 @@ namespace bbwx void TabWidget::OnTabChange( wxEvent& ) { - printf("EED TabWidget::OnTabChange %d\n",mwxNotebook->GetSelection() ); mBox->bbSetOutputSelection( mwxNotebook->GetSelection() ); mBox->bbSignalOutputModification(); } @@ -230,7 +228,7 @@ void LayoutTab::SetTitleTabs() TryInsertWindow(w,"Widget7"); TryInsertWindow(w,"Widget8"); TryInsertWindow(w,"Widget9"); - + //EED2020-04-06 // bbSetOutputWidget( w ); bbSetOutputWidget( tabwidget ); -- 2.45.0