From 433d792763e9cebb963243fbd49fff719f69ed4a Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Wed, 27 Apr 2016 10:02:24 +0200 Subject: [PATCH] #2924 BBTK Feature New Normal - DropFiles box package wx #2804 BBTK Feature New Normal create - std MathOperationVector box --- packages/itk/src/bbitkImageReader.cxx | 4 + packages/std/src/bbstdFilesFromDirectory.cxx | 4 + packages/std/src/bbstdMathOperation.cxx | 17 ++- packages/std/src/bbstdMathOperation.h | 4 +- packages/std/src/bbstdMathOperationVector.cxx | 8 ++ packages/std/src/bbstdMathOperationVector.h | 2 +- packages/wx/src/bbwxDropFiles.cxx | 107 ++++++++++++++++++ packages/wx/src/bbwxDropFiles.h | 52 +++++++++ 8 files changed, 191 insertions(+), 7 deletions(-) create mode 100644 packages/wx/src/bbwxDropFiles.cxx create mode 100644 packages/wx/src/bbwxDropFiles.h diff --git a/packages/itk/src/bbitkImageReader.cxx b/packages/itk/src/bbitkImageReader.cxx index 4f03793..0314698 100644 --- a/packages/itk/src/bbitkImageReader.cxx +++ b/packages/itk/src/bbitkImageReader.cxx @@ -68,6 +68,7 @@ namespace bbitk void ImageReader::Read() { +printf("EED ImageReader::Read start\n"); std::string filename = bbGetInputIn(); itk::ImageIOBase::Pointer genericReader = @@ -83,6 +84,9 @@ namespace bbitk bbtk::TypeInfo typ = GetITKImagePtrTypeInfoFromPixelTypeInfoAndDimension(genericReader->GetComponentTypeInfo(), genericReader->GetNumberOfDimensions()); BBTK_TEMPLATE_ITK_IMAGE_SWITCH( typ, Read); + +printf("EED ImageReader::Read end\n"); + } diff --git a/packages/std/src/bbstdFilesFromDirectory.cxx b/packages/std/src/bbstdFilesFromDirectory.cxx index 6712c8c..5f8feb3 100644 --- a/packages/std/src/bbstdFilesFromDirectory.cxx +++ b/packages/std/src/bbstdFilesFromDirectory.cxx @@ -47,6 +47,8 @@ BBTK_BLACK_BOX_IMPLEMENTATION(FilesFromDirectory,bbtk::AtomicBlackBox); void FilesFromDirectory::Process() { +printf("EED FilesFromDirectory::Process Start\n"); + Filenames.clear(); SimpleFilenames.clear(); DirName = bbGetInputIn(); @@ -55,6 +57,8 @@ void FilesFromDirectory::Process() CleanFilenames( bbGetInputIn() ); bbSetOutputOut(Filenames); bbSetOutputOutSimple(SimpleFilenames); + +printf("EED FilesFromDirectory::Process End\n"); } void FilesFromDirectory::bbUserSetDefaultValues() diff --git a/packages/std/src/bbstdMathOperation.cxx b/packages/std/src/bbstdMathOperation.cxx index 68db443..fdedc10 100644 --- a/packages/std/src/bbstdMathOperation.cxx +++ b/packages/std/src/bbstdMathOperation.cxx @@ -37,11 +37,14 @@ void MathOperation::Process() { firsttime=false; /* initialize random seed: */ - srand (time(NULL)); + srand (time(NULL)); if (bbGetInputType()==7) acum=bbGetInputIn1(); } - if (bbGetInputType()==0) bbSetOutputOut( bbGetInputIn1() + bbGetInputIn2() ); + if (bbGetInputType()==0) + { + bbSetOutputOut( bbGetInputIn1() + bbGetInputIn2() ); + } if (bbGetInputType()==1) bbSetOutputOut( bbGetInputIn1() - bbGetInputIn2() ); if (bbGetInputType()==2) bbSetOutputOut( bbGetInputIn1() * bbGetInputIn2() ); @@ -63,9 +66,12 @@ void MathOperation::Process() if (bbGetInputType()==7) { - bbSetOutputOut( acum ); - acum++; - if (acum>bbGetInputIn2()) acum=bbGetInputIn1(); + if ( back_acum_In1!=bbGetInputIn1() ) acum=bbGetInputIn1(); + if (acumbbGetInputIn2()) acum=bbGetInputIn1(); + back_acum_In1=bbGetInputIn1(); } if (bbGetInputType()==8 ) bbSetOutputOut( rand() % (int) (bbGetInputIn2()-bbGetInputIn1()) + bbGetInputIn1() ); if (bbGetInputType()==9 ) bbSetOutputOut( sin( bbGetInputIn1() ) ); @@ -78,6 +84,7 @@ void MathOperation::Process() if (bbGetInputType()==16) bbSetOutputOut( std::min( bbGetInputIn1(),bbGetInputIn2() ) ); if (bbGetInputType()==17) bbSetOutputOut( std::max( bbGetInputIn1(),bbGetInputIn2() ) ); if (bbGetInputType()==18) bbSetOutputOut( fabs( bbGetInputIn1() ) ); + if (bbGetInputType()==19) bbSetOutputOut( (int)bbGetInputIn1() % (int)bbGetInputIn2() ); } //===== // 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/std/src/bbstdMathOperation.h b/packages/std/src/bbstdMathOperation.h index 351da4e..097545e 100644 --- a/packages/std/src/bbstdMathOperation.h +++ b/packages/std/src/bbstdMathOperation.h @@ -27,6 +27,8 @@ class bbstd_EXPORT MathOperation bool firsttime; double acum; + double back_acum_In1; + double back_acum_In2; //===== // 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) @@ -40,7 +42,7 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(MathOperation,bbtk::AtomicBlackBox); BBTK_CATEGORY("empty"); BBTK_INPUT(MathOperation,In1,"First input",double,""); BBTK_INPUT(MathOperation,In2,"Second input",double,""); - BBTK_INPUT(MathOperation,Type,"Type (defalult 0): 0 adition (default), 1 sustraction In1-In2, 2 multiplication In1*In2, 3 divisiuon In1/In2, 4 sqrt In1, 5 log In1, 6 exp In1, 7 incremental int [In1..In2], 8 random int [In1..In2], 9 sin In1-rad, 10 cos In1-rad, 11 tan In1-rad, 12 asin In 1, 13 acos In1, 14 atan In1, 15 atan2 In1 In2 , 16 min, 17 max, 18 abs In1 ",int,""); + BBTK_INPUT(MathOperation,Type,"Type (defalult 0): 0 adition (default), 1 sustraction In1-In2, 2 multiplication In1*In2, 3 divisiuon In1/In2, 4 sqrt In1, 5 log In1, 6 exp In1, 7 incremental int [In1..In2], 8 random int [In1..In2], 9 sin In1-rad, 10 cos In1-rad, 11 tan In1-rad, 12 asin In 1, 13 acos In1, 14 atan In1, 15 atan2 In1 In2 , 16 min, 17 max, 18 abs In1, 19 module In1%In2 ",int,""); BBTK_OUTPUT(MathOperation,Out,"Output",double,""); BBTK_END_DESCRIBE_BLACK_BOX(MathOperation); diff --git a/packages/std/src/bbstdMathOperationVector.cxx b/packages/std/src/bbstdMathOperationVector.cxx index cebb967..454311f 100644 --- a/packages/std/src/bbstdMathOperationVector.cxx +++ b/packages/std/src/bbstdMathOperationVector.cxx @@ -408,6 +408,14 @@ void MathOperationVector::Process() bbSetOutputOut( resultVec ); } // Type 18 + if (bbGetInputType()==19) + { + for (i=0;i,""); BBTK_INPUT(MathOperationVector,In8,"Input vector 8",std::vector,""); BBTK_INPUT(MathOperationVector,In9,"Input vector 9",std::vector,""); - BBTK_INPUT(MathOperationVector,Type,"Type (defalult 0): 0 adition (default) In0[i]+In1[i]+..+In9[i], -99 adition In0[i] In1[i] ... In[9], 1 sustraction In0[i]-In1[i]-..-In9[i], 2 multiplication In0[i]*In2[i]*...*In9[i], 3 divisiuon In0/In2/.../In9, 4 sqrt In1, 5 log10 In1, 6 exp In1, 7 incremental int [In0..In1], 8 random int [In0..In1], 9 (rad) sin In0, 10 (rad) cos In0, 11 tan (rad) In0, 12 asin In0, 13 acos In0, 14 atan In0, 15 atan2 In0 In1 , 16 min (In0[i],In1[i]..In9[i]), -16 min(In0) min(In1) ... min(In9) , 17 max (In0[i],In1[i]..In9[i]), -17 max(In0) max(In1) ... max(In9) , 18 abs In0 " ,int,""); + BBTK_INPUT(MathOperationVector,Type,"Type (defalult 0): 0 adition (default) In0[i]+In1[i]+..+In9[i], -99 adition In0[i] In1[i] ... In[9], 1 sustraction In0[i]-In1[i]-..-In9[i], 2 multiplication In0[i]*In2[i]*...*In9[i], 3 divisiuon In0/In2/.../In9, 4 sqrt In1, 5 log10 In1, 6 exp In1, 7 incremental int [In0..In1], 8 random int [In0..In1], 9 (rad) sin In0, 10 (rad) cos In0, 11 tan (rad) In0, 12 asin In0, 13 acos In0, 14 atan In0, 15 atan2 In0 In1 , 16 min (In0[i],In1[i]..In9[i]), -16 min(In0) min(In1) ... min(In9) , 17 max (In0[i],In1[i]..In9[i]), -17 max(In0) max(In1) ... max(In9) , 18 abs In0 , 19 module In0[i]%In1[i] " ,int,""); BBTK_OUTPUT(MathOperationVector,Out,"Output vector",std::vector,""); diff --git a/packages/wx/src/bbwxDropFiles.cxx b/packages/wx/src/bbwxDropFiles.cxx new file mode 100644 index 0000000..62585a7 --- /dev/null +++ b/packages/wx/src/bbwxDropFiles.cxx @@ -0,0 +1,107 @@ +//===== +// 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 "bbwxDropFiles.h" +#include "bbwxPackage.h" + +#include "bbtkWx.h" +#include + +namespace bbwx +{ + + +class WxDropFiles: public wxFileDropTarget +{ +public: + WxDropFiles(DropFiles *box): mbox(box){} + bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& arrFilenames); +private: + DropFiles *mbox; +}; + +bool WxDropFiles::OnDropFiles(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), const wxArrayString& arrFilenames) +{ + std::vector tmpLst; + int i,sizeArrFilenames=arrFilenames.GetCount(); + for( i=0 ; ibbSetOutputLstPaths( tmpLst ); + mbox->bbSignalOutputModification( ); + return true; +} + + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,DropFiles) +BBTK_BLACK_BOX_IMPLEMENTATION(DropFiles,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 DropFiles::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') + +// bbSetOutputOut( bbGetInputIn() ); +// std::cout << "Output value = " <SetDropTarget( new WxDropFiles(this) ); + } + +} +//===== +// 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 DropFiles::bbUserSetDefaultValues() +{ + +// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX +// Here we initialize the input 'In' to 0 + bbSetInputWidget(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) +//===== +void DropFiles::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 DropFiles::bbUserFinalizeProcessing() +{ + +// THE FINALIZATION METHOD BODY : +// Here does nothing +// but this is where you should desallocate the internal/output pointers +// if any + +} +} +// EO namespace bbwx + + diff --git a/packages/wx/src/bbwxDropFiles.h b/packages/wx/src/bbwxDropFiles.h new file mode 100644 index 0000000..e6a0f43 --- /dev/null +++ b/packages/wx/src/bbwxDropFiles.h @@ -0,0 +1,52 @@ +//===== +// 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 __bbwxDropFiles_h_INCLUDED__ +#define __bbwxDropFiles_h_INCLUDED__ +#include "bbwx_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" + +#include +#ifndef WX_PRECOMP +// Include your minimal set of headers here, or wx.h +#include +#endif +#include + +namespace bbwx +{ + +class bbwx_EXPORT DropFiles + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(DropFiles,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(Widget,wxWindow*); + BBTK_DECLARE_OUTPUT(LstPaths,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(DropFiles,bbtk::AtomicBlackBox); + BBTK_NAME("DropFiles"); + BBTK_AUTHOR("InfoDev"); + BBTK_DESCRIPTION("No Description."); + BBTK_CATEGORY("empty"); + BBTK_INPUT(DropFiles,Widget,"wxWidget",wxWindow*,""); + BBTK_OUTPUT(DropFiles,LstPaths,"List of paths",std::vector,""); +BBTK_END_DESCRIBE_BLACK_BOX(DropFiles); +//===== +// 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 bbwx + +#endif // __bbwxDropFiles_h_INCLUDED__ + -- 2.47.1