I->InterpretFile(argv[1]);
std::vector<std::string> javascriptBBTK= ((bbtk::InterpreterJavaScript*)(I.get()))->javascriptBBTK ;
FILE *ff=fopen(file.c_str(),"w+");
- fprintf(ff,"import * as bbtk from './bbtk.js' \n" );
//clean this code
+// fprintf(ff,"import * as bbtk from './bbtk.js' \n" );
// fprintf(ff,"export class %s{\n",fileBase.c_str() );
- fprintf(ff," Run(){\n" );
+// fprintf(ff," Run(){\n" );
//clean this code
// fprintf(ff," let mCBjs = new bbtk.ComplexBlackBox('%s')\n",fileBase.c_str());
int i,size=javascriptBBTK.size();
for (i=0; i<size;i++)
{
- fprintf(ff," mCBjs.%s\n", javascriptBBTK[i].c_str() );
+ // fprintf(ff," mCBjs.%s\n", javascriptBBTK[i].c_str() );
+ fprintf(ff,"%s\n", javascriptBBTK[i].c_str() );
}// for i
- fprintf(ff," mCBjs.Execute()\n" );
- fprintf(ff," } \n" );
- fprintf(ff,"} \n" );
+// fprintf(ff," mCBjs.Execute()\n" );
+// fprintf(ff," } \n" );
+// fprintf(ff,"} \n" );
fclose(ff);
} catch (bbtk::Exception e) {
e.Print();
{
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("New( new bbtk."+boxTypeTmp+"('"+boxName+"') )");
+ std::string code(" this.New( new bbtk.bb"+boxTypeTmp+"('"+boxName+"') )");
this->javascriptBBTK.push_back(code);
}
//=========================================================================
const std::string &input) // virtual
{
//ex: mCB.Connection( "Box10" , "Out", "Box11", "In")
- std::string code("Connection('"+boxfrom+"','"+output+"','"+boxto+"','"+input+"')");
+ std::string code(" this.Connection('"+boxfrom+"','"+output+"','"+boxto+"','"+input+"')");
this->javascriptBBTK.push_back(code);
}
//=========================================================================
//=========================================================================
void InterpreterJavaScript::commandInput(const std::string &name,const std::string &box,const std::string &input,const std::string &help)
{
+ std::string code(" this.DECLARE_INPUT('"+name+"','"+box+"."+input+"')");
+ this->javascriptBBTK.push_back(code);
+
}
//=========================================================================
//=========================================================================
void InterpreterJavaScript::commandOutput(const std::string &name,const std::string &box,const std::string &output,const std::string &help)
{
+ std::string code(" this.DECLARE_OUTPUT('"+name+"','"+box+"."+output+"')");
+ this->javascriptBBTK.push_back(code);
}
//=========================================================================
void InterpreterJavaScript::commandSet(const std::string &box,const std::string &input,const std::string &value) // virtual
{
//ex: mCB.Set("Box10","In2","/hola.mhd")
- std::string code("Set('"+box+"','"+input+"','"+value+"')");
+ std::string code(" this.Set('"+box+"','"+input+"','"+value+"')");
this->javascriptBBTK.push_back(code);
}
//=========================================================================
//=========================================================================
void InterpreterJavaScript::commandDefine(const std::string &name,const std::string &pack,const std::string &scriptfilename) // virtual
{
+ // fprintf(ff,"import * as bbtk from './bbtk.js' \n" );
+
+
+
+
+ this->javascriptBBTK.push_back(" ");
+ this->javascriptBBTK.push_back("import * as bbtk from '/bbtk/bbtk.js' ");
+ this->javascriptBBTK.push_back(" ");
+// this->javascriptBBTK.push_back("export class "+pack+"_"+name+" extends bbtk.bbkernel.ComplexBlackBox {");
+ this->javascriptBBTK.push_back("export class "+name+" extends bbtk.bbkernel.ComplexBlackBox {");
+ this->javascriptBBTK.push_back(" ");
+ this->javascriptBBTK.push_back(" constructor(nameBox) {");
+ this->javascriptBBTK.push_back(" super(nameBox)");
+ this->javascriptBBTK.push_back(" this.Init()");
+ this->javascriptBBTK.push_back(" }");
+ this->javascriptBBTK.push_back(" ");
+ this->javascriptBBTK.push_back(" async Init() {");
+/*
+ this->javascriptBBTK.push_back(" ");
+ this->javascriptBBTK.push_back("from bbtk.bbtkBlackBox import *");
+ this->javascriptBBTK.push_back(" ");
+ this->javascriptBBTK.push_back("class "+pack+"_"+name+"(ComplexBlackBox):");
+ this->javascriptBBTK.push_back(" ");
+ this->javascriptBBTK.push_back(" def __init__(self, nameBox):");
+ this->javascriptBBTK.push_back(" super().__init__(nameBox)");
+ this->javascriptBBTK.push_back(" self.Init()");
+ this->javascriptBBTK.push_back(" ");
+ this->javascriptBBTK.push_back(" def Init(self):");
+*/
}
//=========================================================================
//=========================================================================
void InterpreterJavaScript::commandEndDefine() // virtual
{
+ this->javascriptBBTK.push_back(" } // Init ");
+ this->javascriptBBTK.push_back("} // class");
}
//=========================================================================
void InterpreterJavaScript::commandExec(const std::string &word) // virtual
{
//Ex: mCB.AddToExecutableLst("Box13")
- std::string code("AddToExecutableLst('"+word+"')");
+ std::string code(" this.AddToExecutableLst('"+word+"')");
this->javascriptBBTK.push_back(code);
}
//=========================================================================
//=========================================================================
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 *");
this->pythonBBTK.push_back(" ");
this->pythonBBTK.push_back(" self.Init()");
this->pythonBBTK.push_back(" ");
this->pythonBBTK.push_back(" def Init(self):");
-
}
//=========================================================================
BBTK_NAME("Get"+bbtk::HumanTypeName<std::vector<T> >()+"Element");
BBTK_AUTHOR("info-dev@creatis.insa-lyon.fr");
// BBTK_DEFAULT_ADAPTOR();
- BBTK_DESCRIPTION("(C++,Python) Gets the i-th element from the input vector ("+bbtk::TypeName<std::vector<T> >());
+ BBTK_DESCRIPTION("(C++,Python,JavaScript) Gets the i-th element from the input vector ("+bbtk::TypeName<std::vector<T> >());
typedef std::vector<T> Tvector;
BBTK_TEMPLATE_INPUT(GetVectorElement, In,"Input",Tvector);
BBTK_TEMPLATE_INPUT(GetVectorElement, I, "iElement (default 0)",int);
BBTK_NAME("MagicBox");
BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
BBTK_CATEGORY("misc");
- BBTK_DESCRIPTION("(C++,Python) Takes *any kind* of data and copies it to its output. Is a magic box as any box output can be plugged into it and its output can be plugged into any other box input (dynamic type checking, see below), hence it can be put between **any** two boxes. Type matching between its output and the input of the box(es) to which it is connected is made at *run-time*. The pipeline will be executed if the data types : i) match exactly ii) can be transformed by an adaptor iii) are related pointers, i.e. if the output pointer can be upcasted (static_cast) or downcasted (dynamic_cast) to an input type pointer (see the bbtk::any output connection rule in the guide for details). Important uses of the MagicBox are : 1) performing run-time pointer cast, either upward or backward an object hierarchy 2) perform data adaptation (adaptor creation) at run-time vs. pipeline creation time.");
+ BBTK_DESCRIPTION("(C++,Python,JavaScript) Takes *any kind* of data and copies it to its output. Is a magic box as any box output can be plugged into it and its output can be plugged into any other box input (dynamic type checking, see below), hence it can be put between **any** two boxes. Type matching between its output and the input of the box(es) to which it is connected is made at *run-time*. The pipeline will be executed if the data types : i) match exactly ii) can be transformed by an adaptor iii) are related pointers, i.e. if the output pointer can be upcasted (static_cast) or downcasted (dynamic_cast) to an input type pointer (see the bbtk::any output connection rule in the guide for details). Important uses of the MagicBox are : 1) performing run-time pointer cast, either upward or backward an object hierarchy 2) perform data adaptation (adaptor creation) at run-time vs. pipeline creation time.");
AddInputDescriptor
(new bbtk::AtomicBlackBoxInputDescriptor
<blackbox name="MultipleInputs">
<author>laurent.guigues@creatis.insa-lyon.fr</author>
- <description>(C++,Python) This box has multiple Void inputs and one Void output. Hence it relays any input modification to its output. It is usefull to plug different BoxChange outputs into the same BoxExecute input.</description>
+ <description>(C++,Python,JavaScript) This box has multiple Void inputs and one Void output. Hence it relays any input modification to its output. It is usefull to plug different BoxChange outputs into the same BoxExecute input.</description>
<category>misc</category>
<input name="In1" type="bbtk::Void" description="Input 1"/>
BBTK_BEGIN_DESCRIBE_BLACK_BOX(SplitFilePathVector,bbtk::AtomicBlackBox);
BBTK_NAME("SplitFilePathVector");
BBTK_AUTHOR("Info-Dev");
- BBTK_DESCRIPTION("No Description.");
+ BBTK_DESCRIPTION("(C++,JavaScript) No Description.");
BBTK_CATEGORY("empty");
BBTK_INPUT(SplitFilePathVector,In,"PathFileName",std::vector<std::string>,"");
APP_START
CATEGORY:<VOID>
-DESCRIPTION:(C++,Python) Description ??
+DESCRIPTION:(C++,Python,JavaScript) Description ??
AUTHOR:Author ??
EXPORTFORMAT:0
COMPLEXBOX:TRUE
define ImageVtkPropertiesWidget toolsbbtk
author "Author ??"
-description "(C++,Python) Description ??"
+description "(C++,Python,JavaScript) Description ??"
category "<VOID>"
// BBTK_NAME("GetVectorVtkImageDataElement");
BBTK_AUTHOR("info-dev@creatis.insa-lyon.fr");
// BBTK_DEFAULT_ADAPTOR();
- BBTK_DESCRIPTION("Gets the i-th element from the input vector ("+bbtk::TypeName<std::vector<T> >());
+ BBTK_DESCRIPTION("(C++,JavaScript) Gets the i-th element from the input vector ("+bbtk::TypeName<std::vector<T> >());
typedef std::vector<T> Tvector;
BBTK_TEMPLATE_INPUT(GetVectorElement, In,"(default NULL) Input",Tvector);
BBTK_TEMPLATE_INPUT(GetVectorElement, I, "iElement (default 0)",int);
BBTK_BEGIN_DESCRIBE_BLACK_BOX(ImageVtkProperties,bbtk::AtomicBlackBox);
BBTK_NAME("ImageVtkProperties");
BBTK_AUTHOR("Info-Dev Creatis");
- BBTK_DESCRIPTION("(C++,Python) Image information Dim, Spc, Type, MinMax");
+ BBTK_DESCRIPTION("(C++,Python,JavaScript) Image information Dim, Spc, Type, MinMax");
BBTK_CATEGORY("filter");
BBTK_INPUT(ImageVtkProperties,In,"Input image (vtk)",vtkImageData*,"");
BBTK_OUTPUT(ImageVtkProperties,Origin,"Origin", std::vector<double> ,"");
namespace bbvtk
{
-
BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,MarchingCubes)
BBTK_BLACK_BOX_IMPLEMENTATION(MarchingCubes,bbtk::AtomicBlackBox);
-
void MarchingCubes::Process()
{
if (bbGetInputActive()==true)
bbGetVtkObject()->Update();
} // Active
}
-
//-----------------------------------------------------------------
void MarchingCubes::bbUserSetDefaultValues()
{
- BBTK_VTK_SET_DEFAULT_VALUES();
+ BBTK_VTK_SET_DEFAULT_VALUES();
bbSetInputActive(true);
bbSetInputValue(400);
bbSetInputComputeNormalsOn(true);
bbSetInputComputeScalarsOn(true);
}
-
- //-----------------------------------------------------------------
+ //-----------------------------------------------------------------
void MarchingCubes::bbUserInitializeProcessing()
{
BBTK_VTK_INITIALIZE_PROCESSING();
}
-
//-----------------------------------------------------------------
void MarchingCubes::bbUserFinalizeProcessing()
{
BBTK_VTK_FINALIZE_PROCESSING();
}
-
} // EO namespace bbvtk
#endif //_USE_VTK_
BBTK_BEGIN_DESCRIBE_BLACK_BOX(LayoutLine,bbtk::WxBlackBox);
BBTK_NAME("LayoutLine");
BBTK_AUTHOR("eduardo.davila@creatis.insa-lyon.fr");
- BBTK_DESCRIPTION("(C++,Python) LayoutLine widget (wxBoxSizer)");
+ BBTK_DESCRIPTION("(C++,Python,JavaScript) LayoutLine widget (wxBoxSizer)");
// Already inserted for any WxBlackBox BBTK_CATEGORY("widget");
BBTK_INPUT(LayoutLine,Widget1,"widget 1",wxWindow*,"");
BBTK_INPUT(LayoutLine,Widget2,"widget 2",wxWindow*,"");
<blackbox name="OutputText" widget>
<author>laurent.guigues at creatis.insa-lyon.fr</author>
- <description>(C++,Python) Text zone to be inserted into a window (wxStaticText)</description>
+ <description>(C++,Python,JavaScript) Text zone to be inserted into a window (wxStaticText)</description>
<category></category>
<input name="Title" type="std::string" description="Title prepended to the text"/>
BBTK_NAME("Slider");
BBTK_AUTHOR("eduardo.davila@creatis.insa-lyon.fr");
// Already inserted for any WxBlackBox BBTK_CATEGORY("widget");
- BBTK_DESCRIPTION("(C++,Python) Slider widget (wxSlider)");
+ BBTK_DESCRIPTION("(C++,Python,JavaScript) Slider widget (wxSlider)");
BBTK_INPUT(Slider,In, "Initial position of the slider (default 0)", int, "");
BBTK_INPUT(Slider,Min, "Minimum value of the slider (default 0)", int, "");
BBTK_INPUT(Slider,Max, "Maximum value of the slider (default 500)", int, "");