From 9cf063e630e269a83afa9ccc409fb06bcc5b813f Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Fri, 28 Jan 2022 15:40:19 +0100 Subject: [PATCH] #3485 New box AddStringToVector --- packages/std/src/bbstdAddStringToVector.cxx | 81 +++++++++++++++++++++ packages/std/src/bbstdAddStringToVector.h | 66 +++++++++++++++++ packages/std/src/bbstdSetElementVector.h | 9 ++- packages/vtk/src/bbvtkMetaImageReader.cxx | 37 ++++++---- packages/vtk/src/bbvtkText2D.cxx | 65 ++++++++--------- packages/vtk/src/bbvtkText2D.h | 6 ++ packages/wx/src/bbwxComboBox.cxx | 2 + packages/wx/src/bbwxLayoutTab.cxx | 1 + 8 files changed, 213 insertions(+), 54 deletions(-) create mode 100644 packages/std/src/bbstdAddStringToVector.cxx create mode 100644 packages/std/src/bbstdAddStringToVector.h diff --git a/packages/std/src/bbstdAddStringToVector.cxx b/packages/std/src/bbstdAddStringToVector.cxx new file mode 100644 index 0000000..2c80f80 --- /dev/null +++ b/packages/std/src/bbstdAddStringToVector.cxx @@ -0,0 +1,81 @@ +//===== +// 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) +//===== +#include "bbstdAddStringToVector.h" +#include "bbstdPackage.h" +namespace bbstd +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,AddStringToVector) +BBTK_BLACK_BOX_IMPLEMENTATION(AddStringToVector,bbtk::AtomicBlackBox); +//===== +// 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) +//===== +void AddStringToVector::Process() +{ + +// THE MAIN PROCESSING METHOD BODY +// Here we simply set the input 'In' value to the output 'Out' +// And print out the output value +// INPUT/OUTPUT ACCESSORS ARE OF THE FORM : +// void bbSet{Input|Output}NAME(const TYPE&) +// const TYPE& bbGet{Input|Output}NAME() const +// Where : +// * NAME is the name of the input/output +// (the one provided in the attribute 'name' of the tag 'input') +// * TYPE is the C++ type of the input/output +// (the one provided in the attribute 'type' of the tag 'input') + + std::vector lst = bbGetInputStringVector(); + if (bbGetInputIn0().length()!=0) lst.push_back( bbGetInputIn0() ); + if (bbGetInputIn1().length()!=0) lst.push_back( bbGetInputIn1() ); + if (bbGetInputIn2().length()!=0) lst.push_back( bbGetInputIn2() ); + if (bbGetInputIn3().length()!=0) lst.push_back( bbGetInputIn3() ); + if (bbGetInputIn4().length()!=0) lst.push_back( bbGetInputIn4() ); + if (bbGetInputIn5().length()!=0) lst.push_back( bbGetInputIn5() ); + if (bbGetInputIn6().length()!=0) lst.push_back( bbGetInputIn6() ); + if (bbGetInputIn7().length()!=0) lst.push_back( bbGetInputIn7() ); + if (bbGetInputIn8().length()!=0) lst.push_back( bbGetInputIn8() ); + if (bbGetInputIn9().length()!=0) lst.push_back( bbGetInputIn9() ); + bbSetOutputOut( lst ); +} +//===== +// 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) +//===== +void AddStringToVector::bbUserSetDefaultValues() +{ + +// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX +// Here we initialize the input 'In' to 0 +// bbSetInputIn(0); + +} +//===== +// 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) +//===== +void AddStringToVector::bbUserInitializeProcessing() +{ + +// THE INITIALIZATION METHOD BODY : +// Here does nothing +// but this is where you should allocate the internal/output pointers +// if any + + +} +//===== +// 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) +//===== +void AddStringToVector::bbUserFinalizeProcessing() +{ + +// THE FINALIZATION METHOD BODY : +// Here does nothing +// but this is where you should desallocate the internal/output pointers +// if any + +} +} +// EO namespace bbstd + + diff --git a/packages/std/src/bbstdAddStringToVector.h b/packages/std/src/bbstdAddStringToVector.h new file mode 100644 index 0000000..226ecc3 --- /dev/null +++ b/packages/std/src/bbstdAddStringToVector.h @@ -0,0 +1,66 @@ +//===== +// 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) +//===== +#ifndef __bbstdAddStringToVector_h_INCLUDED__ +#define __bbstdAddStringToVector_h_INCLUDED__ + +#include "bbstd_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" + +namespace bbstd +{ + +class bbstd_EXPORT AddStringToVector + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(AddStringToVector,bbtk::AtomicBlackBox); +//===== +// 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) +//===== + BBTK_DECLARE_INPUT(StringVector,std::vector); + BBTK_DECLARE_INPUT(In0,std::string); + BBTK_DECLARE_INPUT(In1,std::string); + BBTK_DECLARE_INPUT(In2,std::string); + BBTK_DECLARE_INPUT(In3,std::string); + BBTK_DECLARE_INPUT(In4,std::string); + BBTK_DECLARE_INPUT(In5,std::string); + BBTK_DECLARE_INPUT(In6,std::string); + BBTK_DECLARE_INPUT(In7,std::string); + BBTK_DECLARE_INPUT(In8,std::string); + BBTK_DECLARE_INPUT(In9,std::string); + BBTK_DECLARE_OUTPUT(Out,std::vector); + BBTK_PROCESS(Process); + void Process(); +//===== +// 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) +//===== +}; + +BBTK_BEGIN_DESCRIBE_BLACK_BOX(AddStringToVector,bbtk::AtomicBlackBox); + BBTK_NAME("AddStringToVector"); + BBTK_AUTHOR("InfoDev"); + BBTK_DESCRIPTION("No Description."); + BBTK_CATEGORY("empty"); + BBTK_INPUT(AddStringToVector,StringVector,"Input string vector",std::vector,""); + BBTK_INPUT(AddStringToVector,In0,"Input",std::string,""); + BBTK_INPUT(AddStringToVector,In1,"Input",std::string,""); + BBTK_INPUT(AddStringToVector,In2,"Input",std::string,""); + BBTK_INPUT(AddStringToVector,In3,"Input",std::string,""); + BBTK_INPUT(AddStringToVector,In4,"Input",std::string,""); + BBTK_INPUT(AddStringToVector,In5,"Input",std::string,""); + BBTK_INPUT(AddStringToVector,In6,"Input",std::string,""); + BBTK_INPUT(AddStringToVector,In7,"Input",std::string,""); + BBTK_INPUT(AddStringToVector,In8,"Input",std::string,""); + BBTK_INPUT(AddStringToVector,In9,"Input",std::string,""); + BBTK_OUTPUT(AddStringToVector,Out,"Output vector",std::vector,""); +BBTK_END_DESCRIBE_BLACK_BOX(AddStringToVector); + +//===== +// 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) +//===== +} // EO namespace bbstd + +#endif // __bbstdAddStringToVector_h_INCLUDED__ + diff --git a/packages/std/src/bbstdSetElementVector.h b/packages/std/src/bbstdSetElementVector.h index 48c215c..d348ddf 100644 --- a/packages/std/src/bbstdSetElementVector.h +++ b/packages/std/src/bbstdSetElementVector.h @@ -52,7 +52,8 @@ namespace bbstd BBTK_DECLARE_INPUT(I,int); BBTK_DECLARE_INPUT(Value,T); BBTK_DECLARE_OUTPUT(Vec,std::vector); - BBTK_PROCESS(DoIt); + BBTK_DECLARE_OUTPUT(PVec,std::vector*); + BBTK_PROCESS(DoIt); void DoIt(); }; //================================================================= @@ -69,6 +70,7 @@ namespace bbstd BBTK_TEMPLATE_INPUT(SetElementVector, I, "id-element (default 0)",int); BBTK_TEMPLATE_INPUT(SetElementVector, Value, "Input Value",T); BBTK_TEMPLATE_OUTPUT(SetElementVector,Vec,"Output Vector",std::vector); + BBTK_TEMPLATE_OUTPUT(SetElementVector,PVec,"Pointer to Vector (the same as the input)",pTvector); BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(SetElementVector); //================================================================= @@ -80,8 +82,9 @@ namespace bbstd { (*( bbGetInputPVec() ))[ bbGetInputI() ] = bbGetInputValue(); } - bbSetOutputVec( *( bbGetInputPVec() ) ); -// bbSignalOutputModification(std::string("Vec")); + bbSetOutputVec( *( bbGetInputPVec() ) ); + bbSetOutputPVec( bbGetInputPVec() ); +// bbSignalOutputModification(std::string("Vec")); } //================================================================= diff --git a/packages/vtk/src/bbvtkMetaImageReader.cxx b/packages/vtk/src/bbvtkMetaImageReader.cxx index e035419..d359bd3 100644 --- a/packages/vtk/src/bbvtkMetaImageReader.cxx +++ b/packages/vtk/src/bbvtkMetaImageReader.cxx @@ -40,22 +40,27 @@ void MetaImageReader::Process() // bbSetOutputOut( bbGetInputIn() ); // std::cout << "Output value = " <SetFileName( bbGetInputIn().c_str() ); - reader->Update(); - bbSetOutputOut( reader->GetOutput() ); - } else { - bbSetOutputOut(NULL); - } // ff - }// .mhdb + if (bbGetInputIn().length()!=0) + { + if (bbGetInputIn().substr(bbGetInputIn().size()-5) == ".mhdb") + { + Read_mhdb( bbGetInputIn() ); + } else { + FILE *ff = fopen( bbGetInputIn().c_str() , "r" ); + if (ff) + { + fclose(ff); + vtkMetaImageReader *reader = vtkMetaImageReader::New(); + reader->SetFileName( bbGetInputIn().c_str() ); + reader->Update(); + bbSetOutputOut( reader->GetOutput() ); + } else { + bbSetOutputOut(NULL); + } // ff + }// .mhdb + } else { + bbSetOutputOut(NULL); + } // if In.length } //===== diff --git a/packages/vtk/src/bbvtkText2D.cxx b/packages/vtk/src/bbvtkText2D.cxx index 5eaa9c2..d270826 100644 --- a/packages/vtk/src/bbvtkText2D.cxx +++ b/packages/vtk/src/bbvtkText2D.cxx @@ -77,27 +77,23 @@ void Text2D::Process() // _textActor->SetTextScaleModeToProp(); _textActor->SetPosition( px*spx , py*spy ); -printf("EED Text2D::Process px=%f py=%f\n",px,py); - // _textActor->SetPosition( 150,150 ); // _textActor->GetPosition2Coordinate()->SetCoordinateSystemToNormalizedViewport(); // _textActor->GetPosition2Coordinate()->SetValue( 0.2 , 0.2 ); // textActor->GetPosition2Coordinate()->SetValue(0.6, 0.1); - vtkTextProperty *tprop = _textActor->GetTextProperty(); - tprop->SetFontSize( bbGetInputFontSize() ); - tprop->SetFontFamilyToArial(); - tprop->SetJustificationToCentered(); -// tprop->BoldOn(); -// tprop->ItalicOn(); -// tprop->ShadowOn(); - - if (bbGetInputColor().size()>=3) - { - tprop->SetColor( bbGetInputColor()[0] , bbGetInputColor()[1] , bbGetInputColor()[2] ); - } - - tprop->SetOpacity( bbGetInputOpacity() ); + vtkTextProperty *tprop = _textActor->GetTextProperty(); + tprop->SetFontSize( bbGetInputFontSize() ); + tprop->SetFontFamilyToArial(); + tprop->SetJustificationToCentered(); + if (bbGetInputFontBold()==true) tprop->BoldOn(); else tprop->BoldOff(); + if (bbGetInputFontItalic()==true) tprop->ItalicOn(); else tprop->ItalicOff(); + if (bbGetInputFontShadow()==true) tprop->ShadowOn(); else tprop->ShadowOff(); + if (bbGetInputColor().size()>=3) + { + tprop->SetColor( bbGetInputColor()[0] , bbGetInputColor()[1] , bbGetInputColor()[2] ); + } + tprop->SetOpacity( bbGetInputOpacity() ); } //===== @@ -105,27 +101,26 @@ printf("EED Text2D::Process px=%f py=%f\n",px,py); //===== void Text2D::bbUserSetDefaultValues() { - // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX // Here we initialize the input 'In' to 0 - - _textActor=NULL; - bbSetInputIn("VOID"); - bbSetInputOpacity(1); - bbSetInputFontSize(14); - std::vector spc; - spc.push_back(1); - spc.push_back(1); - spc.push_back(1); - bbSetInputSpacing(spc); - std::vector color; - color.push_back(0); - color.push_back(0); - color.push_back(1); - bbSetInputColor(color); - - bbSetInputRenderer(NULL); - + _textActor=NULL; + bbSetInputIn("VOID"); + bbSetInputOpacity(1); + bbSetInputFontSize(14); + bbSetInputFontBold(false); + bbSetInputFontItalic(false); + bbSetInputFontShadow(false); + std::vector spc; + spc.push_back(1); + spc.push_back(1); + spc.push_back(1); + bbSetInputSpacing(spc); + std::vector color; + color.push_back(0); + color.push_back(0); + color.push_back(1); + bbSetInputColor(color); + bbSetInputRenderer(NULL); } //===== // 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) diff --git a/packages/vtk/src/bbvtkText2D.h b/packages/vtk/src/bbvtkText2D.h index ff85ca4..eac3356 100644 --- a/packages/vtk/src/bbvtkText2D.h +++ b/packages/vtk/src/bbvtkText2D.h @@ -28,6 +28,9 @@ BBTK_DECLARE_INPUT(In,std::string); BBTK_DECLARE_INPUT(Spacing,std::vector); BBTK_DECLARE_INPUT(Opacity,double); BBTK_DECLARE_INPUT(FontSize,int); + BBTK_DECLARE_INPUT(FontBold,bool); + BBTK_DECLARE_INPUT(FontItalic,bool); + BBTK_DECLARE_INPUT(FontShadow,bool); BBTK_DECLARE_INPUT(Color,std::vector); BBTK_DECLARE_OUTPUT( Out , vtkProp* ); BBTK_PROCESS(Process); @@ -52,6 +55,9 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(Text2D,bbtk::AtomicBlackBox); BBTK_INPUT(Text2D,Opacity,"Pacity (default 1)",double,""); BBTK_INPUT(Text2D,Renderer,"Vtk Rendere ",vtkRenderer*,""); BBTK_INPUT(Text2D,FontSize,"Font size (default 14)",int,""); + BBTK_INPUT(Text2D,FontBold,"(default false) Bold true/false",bool,""); + BBTK_INPUT(Text2D,FontItalic,"(default false) Italic true/false",bool,""); + BBTK_INPUT(Text2D,FontShadow,"(default false) Shadow true/false",bool,""); BBTK_INPUT(Text2D,Color,"vector color [r,g,b] (default [0,0,1])",std::vector,""); BBTK_OUTPUT(Text2D,Out,"vtk Prop",vtkProp*,""); diff --git a/packages/wx/src/bbwxComboBox.cxx b/packages/wx/src/bbwxComboBox.cxx index d081d32..96b5ad7 100644 --- a/packages/wx/src/bbwxComboBox.cxx +++ b/packages/wx/src/bbwxComboBox.cxx @@ -187,6 +187,7 @@ void ComboBoxWidget::FillItems( int iSelection, std::vector< std::string > lstIn #if defined(_WIN32) // Patch to put spaces at the beginin #else + /* // Patch to put spaces at the beginin int strLength=-1; // Looking for the longest string @@ -204,6 +205,7 @@ void ComboBoxWidget::FillItems( int iSelection, std::vector< std::string > lstIn lstIn[i]=" "+lstIn[i]; // spaces characters } // for ii } // for i + */ #endif // defined(_WIN32) itemcontainer->Clear(); diff --git a/packages/wx/src/bbwxLayoutTab.cxx b/packages/wx/src/bbwxLayoutTab.cxx index 3655a77..6923062 100644 --- a/packages/wx/src/bbwxLayoutTab.cxx +++ b/packages/wx/src/bbwxLayoutTab.cxx @@ -122,6 +122,7 @@ wxNotebook* TabWidget::GetmwxNotebook() bbSetInputWidget7(NULL); bbSetInputWidget8(NULL); bbSetInputWidget9(NULL); + bbSetOutputSelection( 0 ); } //----------------------------------------------------------------- -- 2.47.1