+//=======================================================================
+void Interpreter::NewGUI(const std::string& boxname,
+ const std::string& instanceName)
+{
+ std::string typeName = instanceName+"Type";
+ std::stringstream* s = new std::stringstream;
+ // create the complex box
+ (*s) << "define "<<typeName<<std::endl;
+ // (*s) << " description 'Automatically generated user interface for the box "
+ // << boxname << "'" <<std::endl;
+ // create the Layout box
+ (*s) << " load wx"<<std::endl;
+ (*s) << " new LayoutLine layout"<<std::endl;
+ // create the output 'Widget'
+ (*s) << " output Widget layout.Widget Widget"<<std::endl;
+ // the box change output
+ (*s) << " new MultipleInputs change"<<std::endl;
+ (*s) << " output BoxChange change.Out BoxChange"<<std::endl;
+
+ // Browse the inputs of the box in order to find which ones are not
+ // connected and can be adapted from a widget adaptor
+ // vector which stores the list of inputs of the box which must be connected
+ std::vector<std::string> in;
+
+ Factory::Pointer F = mExecuter->GetFactory();
+ /*
+ Package::Pointer user = F->GetPackage("user");
+ */
+ ComplexBlackBoxDescriptor::Pointer workspace = mExecuter->GetWorkspace();
+
+ if (workspace==0)
+ {
+ delete s;
+ bbtkError("Interpreter::CreateGUI : could not access the executer workspace");
+ }
+
+
+ /*
+ (ComplexBlackBoxDescriptor::Pointer)(user->GetBlackBoxMap().find("workspace")->second.get());
+ */
+
+ BlackBox::Pointer box = workspace->GetPrototype()->bbGetBlackBox(boxname);
+ // BlackBox::InputConnectorMapType incm = box->bbGetInputConnectorMap();
+ int nb = 0;
+ BlackBox::InputConnectorMapType::iterator i;
+ for (i=box->bbGetInputConnectorMap().begin();
+ i!=box->bbGetInputConnectorMap().end();
+ ++i)
+ {
+ // If the input is connected : continue
+ if (i->second->IsConnected()) continue;
+ // Get the input descriptor
+ const BlackBoxInputDescriptor* d = box->bbGetDescriptor()->GetInputDescriptor(i->first);
+ // If it is a "system" input : skip it
+ if ( ( d->GetCreatorTypeInfo() == typeid(AtomicBlackBoxDescriptor)) ||
+ ( d->GetCreatorTypeInfo() == typeid(WxBlackBoxDescriptor)) )
+ continue;
+ bool widok = true;
+ std::string widget,adaptor;
+ // try to find a widget adaptor
+ if (F->FindWidgetAdaptor(DataInfo(d->GetTypeInfo(),""),
+ d->GetDataInfo(),
+ adaptor))
+ {
+ // command to create the adaptor
+ (*s) << " new "<<adaptor<<" "<<i->first<<std::endl;
+ // Sets the label of the widget adaptor to the name of the input
+ (*s) << " set "<<i->first<<".Label "<<i->first<<std::endl;
+ // Sets the initial value of the widget to the value of the input
+ (*s) << " set "<<i->first<<".In \" "
+ <<box->bbGetInputAsString(i->first)<<"\""
+ << std::endl;
+ // store the input name
+ in.push_back(i->first);
+ (*s) << " connect "<<i->first<<".Widget layout.Widget"<<in.size()<<std::endl;
+ //<i->first<<"'"<<std::endl;
+ (*s) << " connect "<<i->first<<".BoxChange change.In"<<in.size()<<std::endl;
+ }
+ // try to find a two pieces adaptor
+ else if (F->FindWidgetAdaptor2(DataInfo(d->GetTypeInfo(),""),
+ d->GetDataInfo(),
+ widget,adaptor) )
+ {
+ // command to create the widget
+ (*s) << " new "<<widget<<" "<<i->first<<"Widget"<<std::endl;
+ // command to create the adaptor
+ (*s) << " new "<<adaptor<<" "<<i->first<<std::endl;
+ // connect the two
+ (*s) << " connect "<<i->first<<"Widget.Out "
+ <<i->first<<".In"<<std::endl;
+ // Sets the label of the widget adaptor to the name of the input
+ (*s) << " set "<<i->first<<"Widget.Label "<<i->first<<std::endl;
+ // Sets the initial value of the widget to the value of the input
+ (*s) << " set "<<i->first<<"Widget.In \" "
+ <<box->bbGetInputAsString(i->first)<<"\""<< std::endl;
+ // store the input name
+ in.push_back(i->first);
+ (*s) << " connect "<<i->first<<"Widget.Widget layout.Widget"<<in.size()<<std::endl;
+ //<i->first<<"'"<<std::endl;
+ (*s) << " connect "<<i->first<<"Widget.BoxChange change.In"<<in.size()<<std::endl;
+
+ }
+ // try to find an adaptor from string
+ // If found then can create a text input which
+ // will be automatically adapted
+ else if (F->FindAdaptor(DataInfo(typeid(std::string),""),
+ d->GetDataInfo(),
+ adaptor))
+ {
+ // command to create the adaptor
+ (*s) << " new InputText "<<i->first<<std::endl;
+ // Sets the label of the widget adaptor to the name of the input
+ (*s) << " set "<<i->first<<".Title "<<i->first<<std::endl;
+ // Sets the initial value of the widget to the value of the input
+ (*s) << " set "<<i->first<<".In \" "
+ <<box->bbGetInputAsString(i->first)<<"\""<< std::endl;
+ // store the input name
+ in.push_back(i->first);
+ (*s) << " connect "<<i->first<<".Widget layout.Widget"<<in.size()<<std::endl;
+ //<i->first<<"'"<<std::endl;
+ (*s) << " connect "<<i->first<<".BoxChange change.In"<<in.size()<<std::endl;
+
+ }
+ else
+ {
+ widok = false;
+ }
+ if (widok)
+ {
+ // command to create the output
+ (*s) << " output "<<i->first<<" "
+ <<i->first<<".Out "<<i->first<<std::endl;
+ // <<" Output of the widget which allows to set "
+
+ }
+ }
+ // Inputs for window properties
+ (*s) << " input WinTitle layout.WinTitle Title"<<std::endl;
+ (*s) << " input WinWidth layout.WinWidth Width"<<std::endl;
+ (*s) << " input WinHeight layout.WinHeight Height"<<std::endl;
+ (*s) << " input WinDialog layout.WinDialog Dialog"<<std::endl;
+ (*s) << " input WinHide layout.WinHide Hide"<<std::endl;
+
+
+
+ // Execute the box executes the layout
+ (*s) << " exec layout" << std::endl;
+ (*s) << "endefine" << std::endl;
+ // (*s) << "help "<< typeName<< std::endl;
+ // instanciate the box and connect it
+ (*s) << "new "<<typeName<<" "<<instanceName<<std::endl;
+ // connections
+ std::vector<std::string>::iterator j;
+ for (j=in.begin();j!=in.end();++j)
+ {
+ // connect
+ (*s) << "connect "<<instanceName<<"."<<*j<<" "
+ << boxname<<"."<<*j<<std::endl;
+ }
+ // That's all folks ! now execute the commands :
+ SwitchToStream(s);
+}
+//=======================================================================
+
+
+
+ //==========================================================================
+ void Interpreter::ObjectInfo(const std::string& name)
+ {
+ Object:: PrintObjectInfo(name);
+ }
+ //==========================================================================
+ //==========================================================================
+ std::string Interpreter::GetObjectName() const
+ {
+ return std::string("Interpreter");
+ }
+ //==========================================================================
+
+ //==========================================================================
+ std::string Interpreter::GetObjectInfo() const
+ {
+ std::stringstream i;
+ return i.str();
+ }
+ //==========================================================================
+
+ //==========================================================================
+size_t Interpreter::GetObjectSize() const
+{
+ size_t s = Superclass::GetObjectSize();
+ s += Interpreter::GetObjectInternalSize();
+ return s;
+ }
+ //==========================================================================
+ //==========================================================================
+size_t Interpreter::GetObjectInternalSize() const
+{
+ size_t s = sizeof(Interpreter);
+ return s;
+ }
+ //==========================================================================
+ //==========================================================================
+ size_t Interpreter::GetObjectRecursiveSize() const
+ {
+ size_t s = Superclass::GetObjectRecursiveSize();
+ s += Interpreter::GetObjectInternalSize();
+ s += mExecuter->GetObjectRecursiveSize();
+ return s;
+ }
+ //==========================================================================