From bee168d199ed373ddd20f536d67f41bdce41500e Mon Sep 17 00:00:00 2001 From: "eduardo.davila@creatis.insa-lyon.fr" Date: Wed, 18 Sep 2024 17:03:11 +0200 Subject: [PATCH] Clean code --- kernel/src/bbtkInterpreterPython.cxx | 14 ++++++++---- packages/std/src/bbstdDiv.xml | 2 +- packages/std/src/bbstdReadLinesString.h | 2 +- packages/std/src/bbstdReplaceCleanString.h | 2 +- packages/std/src/bbstdVectorFilterDouble.cxx | 24 ++++++++++++++++++++ packages/std/src/bbstdVectorFilterDouble.h | 4 ++-- packages/wx/src/bbwxCheckBox.h | 4 ++-- packages/wx/src/bbwxComboBox.h | 2 +- 8 files changed, 42 insertions(+), 12 deletions(-) diff --git a/kernel/src/bbtkInterpreterPython.cxx b/kernel/src/bbtkInterpreterPython.cxx index e47966f..d5ce12a 100644 --- a/kernel/src/bbtkInterpreterPython.cxx +++ b/kernel/src/bbtkInterpreterPython.cxx @@ -73,9 +73,9 @@ namespace bbtk { int pos = boxType.find( std::string(":") ); std::string boxTypeTmp=boxType; - boxTypeTmp.replace(pos,1,"_"); + boxTypeTmp.replace(pos,1,"."); // ex: mCB.New( bbtkBlackBox.std_ConcatString("Box10") ) - std::string code(" self.New( "+boxTypeTmp+"('"+boxName+"') )"); + std::string code(" self.New( bbtk.bb"+boxTypeTmp+"('"+boxName+"') )"); this->pythonBBTK.push_back(code); } //========================================================================= @@ -123,9 +123,15 @@ namespace bbtk void InterpreterPython::commandDefine(const std::string &name,const std::string &pack,const std::string &scriptfilename) // virtual { this->pythonBBTK.push_back(" "); - this->pythonBBTK.push_back("from bbtk.bbtkBlackBox import *"); + +//EED2024-07-29 +// this->pythonBBTK.push_back("from bbtk.bbtkBlackBox import *"); +// this->pythonBBTK.push_back(" "); +// this->pythonBBTK.push_back("class "+pack+"_"+name+"(ComplexBlackBox):"); + this->pythonBBTK.push_back("import bbtk.bbtk as bbtk"); this->pythonBBTK.push_back(" "); - this->pythonBBTK.push_back("class "+pack+"_"+name+"(ComplexBlackBox):"); + this->pythonBBTK.push_back("class "+name+"(bbtk.bbkernel.ComplexBlackBox):"); + this->pythonBBTK.push_back(" "); this->pythonBBTK.push_back(" def __init__(self, nameBox):"); this->pythonBBTK.push_back(" super().__init__(nameBox)"); diff --git a/packages/std/src/bbstdDiv.xml b/packages/std/src/bbstdDiv.xml index 6bc651c..5f2f721 100644 --- a/packages/std/src/bbstdDiv.xml +++ b/packages/std/src/bbstdDiv.xml @@ -3,7 +3,7 @@ laurent.guigues@creatis.insa-lyon.fr - (C++,Python) Divides its inputs + (C++,Python,JavaScript) Divides its inputs math diff --git a/packages/std/src/bbstdReadLinesString.h b/packages/std/src/bbstdReadLinesString.h index 2b8c32b..25fc72c 100644 --- a/packages/std/src/bbstdReadLinesString.h +++ b/packages/std/src/bbstdReadLinesString.h @@ -30,7 +30,7 @@ class bbstd_EXPORT ReadLinesString BBTK_BEGIN_DESCRIBE_BLACK_BOX(ReadLinesString,bbtk::AtomicBlackBox); BBTK_NAME("ReadLinesString"); BBTK_AUTHOR("Info-Dev"); - BBTK_DESCRIPTION("No Description."); + BBTK_DESCRIPTION("(C++,JavaScipt) No Description."); BBTK_CATEGORY("empty"); BBTK_INPUT(ReadLinesString,FileName,"FileName",std::string,""); diff --git a/packages/std/src/bbstdReplaceCleanString.h b/packages/std/src/bbstdReplaceCleanString.h index ebd2718..84a5774 100644 --- a/packages/std/src/bbstdReplaceCleanString.h +++ b/packages/std/src/bbstdReplaceCleanString.h @@ -33,7 +33,7 @@ class bbstd_EXPORT ReplaceCleanString BBTK_BEGIN_DESCRIBE_BLACK_BOX(ReplaceCleanString,bbtk::AtomicBlackBox); BBTK_NAME("ReplaceCleanString"); BBTK_AUTHOR("InfoDev"); - BBTK_DESCRIPTION("(C++,Python) No Description."); + BBTK_DESCRIPTION("(C++,Python,JavaScript) No Description."); BBTK_CATEGORY("empty"); BBTK_INPUT(ReplaceCleanString,In,"Input string",std::string,""); BBTK_INPUT(ReplaceCleanString,Replace,"New string to be put",std::string,""); diff --git a/packages/std/src/bbstdVectorFilterDouble.cxx b/packages/std/src/bbstdVectorFilterDouble.cxx index c132e91..1ef07bc 100644 --- a/packages/std/src/bbstdVectorFilterDouble.cxx +++ b/packages/std/src/bbstdVectorFilterDouble.cxx @@ -466,6 +466,30 @@ void VectorFilterDouble::Process() } // for iSeg } // if k1 not empty } + } // Type 14 + if (bbGetInputType()==15) // 15 swhitch element in a point k1=0 yz, k1=1 nothing k2=2 xz + { + double x,y,z; + double xx,yy,zz; + std::vector k1 =bbGetInputk1(); + if ( (In0.size()==3) && (k1.size()==1 ) ) + { + if (k1[0]==0) { + Out0.push_back( In0[0] ); // x + Out0.push_back( In0[2] ); // z + Out0.push_back( In0[1] ); // y + } + if (k1[1]==1) { + Out0.push_back( In0[0] ); // x + Out0.push_back( In0[1] ); // y + Out0.push_back( In0[2] ); // z + } + if (k1[2]==2) { + Out0.push_back( In0[2] ); // z + Out0.push_back( In0[1] ); // y + Out0.push_back( In0[0] ); // x + } + } // if In0.size and k1.size } // Type 14 bbSetOutputOut0( Out0 ); diff --git a/packages/std/src/bbstdVectorFilterDouble.h b/packages/std/src/bbstdVectorFilterDouble.h index c9d9438..08b525f 100644 --- a/packages/std/src/bbstdVectorFilterDouble.h +++ b/packages/std/src/bbstdVectorFilterDouble.h @@ -52,8 +52,8 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(VectorFilterDouble,bbtk::AtomicBlackBox); BBTK_AUTHOR("InfoDev"); BBTK_DESCRIPTION("No Description."); BBTK_CATEGORY("empty"); - BBTK_INPUT(VectorFilterDouble,Type,"default (0) 0=Erase duplicated lines, 1=Redimention Vectors, 2=Insert intermediat points,3=Adition k1, 4=Substraction k1, 5=Multilication k1, 6=Division k1, 7=Connect mesh X1,Y1,Z1,idxs1,X2,X2,X2,idx2, 8=Order All vectors with the logic of In0 , 9=Invert Vectors, 10=Nearest Point in the vector. In3PointXYZ In0LstX In1LstY In2LstZ (Out0-index Out1-PointXYZ), 11=Mul Spacing (K1[spcX,spcY,spcZ]=Spacing), 12=Div Spacing (K1[spcX,spcY,spcZ]=Spacing), 13=Distance pointIn0 and pontIn1, 14=Select specific segments [k1] in In0=lstPx In1=lstPy In2=lstPz In3=lstIndex (if k1 empty all segments are selected) ",int,""); - BBTK_INPUT(VectorFilterDouble,k1,"(default [0]) nothing (Type0), k1[0]=new size vectors (Type 1) , nothing (Type2), k1[0] = Addition const. (Type 3), k1[0] = Substraction const. (Type 4), k1[0] = Multiplication const. (Type 5) , k1[0] = Division const. (Type 6) , k1[spcX,spcY,spcZ] MulSpc In0_X,In1_Y,In2_Z (type 11), k1[spcX,spcY,spcZ] DivSpc In0_X,In1_Y,In2_Z (type 12) , k1[segment1, segment2,..] (type 14) ",std::vector,""); + BBTK_INPUT(VectorFilterDouble,Type,"default (0) 0=Erase duplicated lines, 1=Redimention Vectors, 2=Insert intermediat points,3=Adition k1, 4=Substraction k1, 5=Multilication k1, 6=Division k1, 7=Connect mesh X1,Y1,Z1,idxs1,X2,X2,X2,idx2, 8=Order All vectors with the logic of In0 , 9=Invert Vectors, 10=Nearest Point in the vector. In3PointXYZ In0LstX In1LstY In2LstZ (Out0-index Out1-PointXYZ), 11=Mul Spacing (K1[spcX,spcY,spcZ]=Spacing), 12=Div Spacing (K1[spcX,spcY,spcZ]=Spacing), 13=Distance pointIn0 and pontIn1, 14=Select specific segments [k1] in In0=lstPx In1=lstPy In2=lstPz In3=lstIndex (if k1 empty all segments are selected) , 15 swhitch element in a point k1=0 yz, k1=1 nothing k2=2 xz",int,""); + BBTK_INPUT(VectorFilterDouble,k1,"(default [0]) nothing (Type0), k1[0]=new size vectors (Type 1) , nothing (Type2), k1[0] = Addition const. (Type 3), k1[0] = Substraction const. (Type 4), k1[0] = Multiplication const. (Type 5) , k1[0] = Division const. (Type 6) , k1[spcX,spcY,spcZ] MulSpc In0_X,In1_Y,In2_Z (type 11), k1[spcX,spcY,spcZ] DivSpc In0_X,In1_Y,In2_Z (type 12) , k1[segment1, segment2,..] (type 14) , direction (type 15) ",std::vector,""); BBTK_INPUT(VectorFilterDouble,In0,"Input vector",std::vector,""); BBTK_INPUT(VectorFilterDouble,In1,"Input vector",std::vector,""); BBTK_INPUT(VectorFilterDouble,In2,"Input vector",std::vector,""); diff --git a/packages/wx/src/bbwxCheckBox.h b/packages/wx/src/bbwxCheckBox.h index ef5ec23..820e2ae 100644 --- a/packages/wx/src/bbwxCheckBox.h +++ b/packages/wx/src/bbwxCheckBox.h @@ -151,11 +151,11 @@ namespace bbwx BBTK_NAME("CheckBox"); BBTK_AUTHOR("jpr@creatis.insa-lyon.fr"); // Already inserted for any WxBlackBox BBTK_CATEGORY("widget"); - BBTK_DESCRIPTION("(C++,Python) CheckBox widget"); + BBTK_DESCRIPTION("(C++,Python,JavaScript) CheckBox widget"); BBTK_INPUT(CheckBox, In, "Initial value of the CheckBox (default false)",bool, ""); BBTK_INPUT(CheckBox, Title,"Title shown above the CheckBox (default '') ", std::string,""); BBTK_OUTPUT(CheckBox,Out, "Current value of the CheckBox", bool, ""); - BBTK_INPUT(CheckBox,ReactiveOnKeystroke,"0: no event generated when the checkbox is clicked on, 1: event generated when the checkbox is clicked on (default 1) ", int,""); + BBTK_INPUT(CheckBox,ReactiveOnKeystroke,"(default 1) 0: no event generated when the checkbox is clicked on, 1: event generated when the checkbox is clicked on ", int,""); BBTK_END_DESCRIBE_BLACK_BOX(CheckBox); //================================================================= diff --git a/packages/wx/src/bbwxComboBox.h b/packages/wx/src/bbwxComboBox.h index 68ea71c..59735b1 100644 --- a/packages/wx/src/bbwxComboBox.h +++ b/packages/wx/src/bbwxComboBox.h @@ -40,7 +40,7 @@ class bbwx_EXPORT ComboBox BBTK_BEGIN_DESCRIBE_BLACK_BOX(ComboBox,bbtk::WxBlackBox); BBTK_NAME("ComboBox"); BBTK_AUTHOR("Info-Dev"); - BBTK_DESCRIPTION("(C++,Python) wxComboBox"); + BBTK_DESCRIPTION("(C++,Python,JavaScript) wxComboBox"); BBTK_CATEGORY("__CategoryBlackBox__"); BBTK_INPUT(ComboBox,Title,"Title prepended to the text",std::string,""); -- 2.46.2