+ void wxVtkSceneManager::loadDiagram(ifstream &inputStream)
+ {
+
+ std::string line="";
+ char delims[] = ":";
+ char *result = NULL;
+ getline(inputStream,line);
+
+ bool start = false;
+ while ( !inputStream.eof() )
+ {
+ if(line=="" || line[0]=='#')
+ {
+ getline(inputStream,line);
+ }
+ else if(line=="APP_START")
+ {
+ start = true;
+ break;
+ }
+ }
+
+ if(start)
+ {
+ //----------
+ getline(inputStream,line);//BOXES:num
+ char boxes[9];
+ strcpy( boxes, line.c_str() );
+ result = strtok( boxes, delims );
+ result = strtok( NULL, delims );
+
+ int numBoxes;
+ std::istringstream is(result);
+ is >> numBoxes;
+
+ for(int i = 0;i<numBoxes;i++)
+ {
+ //----------
+ getline(inputStream,line);//BOX
+ getline(inputStream,line);//package:type:name
+ char box[100];
+ strcpy( box, line.c_str() );
+ result = strtok( box, delims );//package
+ std::string package(result);
+ result = strtok( NULL, delims );//type
+ std::string type(result);
+ result = strtok( NULL, delims );//name
+ std::string name(result);
+
+ getline(inputStream,line);//ISEXEC:TRUE|FALSE
+ char exec[15];
+ strcpy( exec, line.c_str() );
+ result = strtok( exec, delims );//ISEXEC
+ result = strtok( NULL, delims );//TRUE|FALSE
+ std::string isExec(result);
+
+ //----------
+ getline(inputStream,line);//xInic:yInic:zInic
+ char coord[80];
+ strcpy( coord, line.c_str() );
+ result = strtok( coord, delims );//xInic
+ std::string xInic(result);
+ result = strtok( NULL, delims );//yInic
+ std::string yInic(result);
+ result = strtok( NULL, delims );//zInic
+ std::string zInic(result);
+
+ double xIn, yIn, zIn;
+ std::istringstream xSt(xInic);
+ xSt >> xIn;
+ std::istringstream ySt(yInic);
+ ySt >> yIn;
+ std::istringstream zSt(zInic);
+ zSt >> zIn;
+
+ //----------
+ getline(inputStream,line);//xEnd:yEnd:zEnd
+ strcpy( coord, line.c_str() );
+ result = strtok( coord, delims );//xEnd
+ std::string xEnd(result);
+ result = strtok( NULL, delims );//yEnd
+ std::string yEnd(result);
+ result = strtok( NULL, delims );//zEnd
+ std::string zEnd(result);
+
+ double xEn, yEn, zEn;
+ std::istringstream xEt(xEnd);
+ xEt >> xEn;
+ std::istringstream yEt(yEnd);
+ yEt >> yEn;
+ std::istringstream zEt(zEnd);
+ zEt >> zEn;
+
+ int idBox = createGBlackBox(0,0,package,type);
+ GObjectController *cont = _controllers[idBox];
+ GBlackBoxModel *bbmod = (GBlackBoxModel*)cont->getModel();
+ bbmod->setBBTKName(name);
+ bbmod->setInicPoint(xIn,yIn,zIn);
+ bbmod->setFinalPoint(xEn,yEn,zEn);
+ if(isExec=="TRUE")
+ {
+ bbmod->setExecutable(true);
+ }
+ else if(isExec=="FALSE")
+ {
+ bbmod->setExecutable(false);
+ }
+
+ //----------
+ getline(inputStream,line);//PORT o FIN_BOX
+ std::string port=line.substr(0,4);
+ while(port=="PORT")
+ {
+ getline(inputStream,line);//name:value
+ char poort[20];
+ strcpy( poort, line.c_str() );
+ result = strtok( poort, delims );//name
+ std::string name(result);
+ result = strtok( NULL, delims );//value
+ std::string value(result);
+
+ bbmod->setValueToInput(name,value);
+
+ getline(inputStream,line);//PORT o FIN_BOX
+ port=line.substr(0,4);
+ }
+
+ bbmod->notifyObservers(_idManager);
+ }
+
+ /// CONNECTIONS
+ //----------
+ getline(inputStream,line);//CONNECTIONS:num
+ char conns[15];
+ strcpy( conns, line.c_str() );
+ result = strtok( conns, delims );
+ result = strtok( NULL, delims );
+
+ int numConns;
+ std::istringstream isCons(result);
+ isCons >> numConns;
+
+ for(int i = 0;i<numConns;i++)
+ {
+ //----------
+ getline(inputStream,line);//CONNECTION
+ getline(inputStream,line);//Startbox.PortName:EndBox.PortName
+
+ char connec[100];
+ strcpy( connec, line.c_str() );
+ result = strtok( connec, delims );
+ std::string nameStartBox(result);
+ result = strtok( NULL, delims );
+ std::string nameStartPort(result);
+ result = strtok( NULL, delims );
+ std::string nameEndBox(result);
+ result = strtok( NULL, delims );
+ std::string nameEndPort(result);
+
+ std::vector<int> lstB = getBoxes();
+
+ GPortModel *startP=NULL;
+ GPortModel *endP=NULL;
+ for(int j = 0;j<lstB.size();j++)
+ {
+ int idB = lstB[j];
+ GBlackBoxModel *bbMod = (GBlackBoxModel*)_controllers[idB]->getModel();
+ if(_controllers[idB]->getModel()->getBBTKName()==nameStartBox)
+ {
+ startP = bbMod->getOutputPort(nameStartPort);
+ }
+ else if(_controllers[idB]->getModel()->getBBTKName()==nameEndBox)
+ {
+ endP = bbMod->getInputPort(nameEndPort);
+ }
+ }
+
+ int idCon = createGConnector(startP);
+ _worldState = NOTHING_HAPPENS;
+ GConnectorController *tempp = (GConnectorController*)_controllers[idCon];
+
+ GConnectorModel *conMod = (GConnectorModel*)tempp->getModel();
+ vtkGConnectorView *conView = (vtkGConnectorView*)tempp->getView();
+ tempp->endContourCreation();
+ conMod->setEndPort(endP);
+ conView->updateStartEndPoints();
+
+ }
+ }
+
+ }
+
+ //=========================================================================
+