X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FEditorGraphicBBS%2FbbsWxGUIEditorGraphic%2FwxVtkSceneManager.cxx;h=3c8825175f33f32c5ba19337e7bcf54b4a42cf02;hb=227a0737f17511cbe4910c072efe2806286427ed;hp=dae6833dea58c02ae75a5e1959ac2fef70f076f2;hpb=20d8646f40b23f856e8514f4201f4a371d15abd9;p=bbtkGEditor.git diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx index dae6833..3c88251 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx @@ -43,7 +43,6 @@ namespace bbtk //========================================================================= wxVtkSceneManager::wxVtkSceneManager(wxGEditorTabPanel *parent, wxVtk3DBaseView *baseView,int idManager) { - printf ("EED %p wxVtkSceneManager()\n" , this ); _parent = parent; _numBoxes=0; _idManager=idManager; @@ -56,11 +55,14 @@ namespace bbtk //EED02JUIN2010 printf ("RaC-EED 21-06-2010 %p wxVtkSceneManager::wxVtkSceneManager If you comment this line, the drag and drop functionnality is not initialized.\n" , this ); _baseView->GetWxVTKRenderWindowInteractor()->SetDropTarget((wxDropTarget*)parent); + configureBaseView(); _worldState=NOTHING_HAPPENS; registerController(this); } + _idConnectionInCreation=-1; + _contLastId=0; } @@ -104,21 +106,67 @@ namespace bbtk } //========================================================================= + + std::string wxVtkSceneManager::generateANewNameForABox() + { + std::stringstream boxname; + if(_numBoxes<10) + { + boxname << "Box0" << _numBoxes; + }else{ + boxname << "Box" << _numBoxes; + } + _numBoxes++; + return boxname.str(); + } - int wxVtkSceneManager::createGBlackBox(int x, int y, std::string packageName, std::string boxType) + //========================================================================= + + std::string wxVtkSceneManager::findANewNameForABox() { - int windowWidth=_baseView->GetRenWin()->GetSize()[0]; - int windowHeight=_baseView->GetRenWin()->GetSize()[1]; + std::string boxname=generateANewNameForABox(); - int type = GBLACKBOX; + while (boxExist(boxname)==true) + { + boxname=generateANewNameForABox(); + } // while + + return boxname; + } + + //========================================================================= +//ups1 eed + void wxVtkSceneManager::configGBlackBox(int idBox, double xIn, double yIn, double zIn, std::string name, bool boxExecutable,double xEn,double yEn,double zEn) + { + GObjectController *cont = _controllers[idBox]; + GBlackBoxModel *bbmod = (GBlackBoxModel*)cont->getModel(); + bbmod->setBBTKName(name); + bbmod->setInicPoint(xIn,yIn,zIn); + bbmod->setFinalPoint(xEn,yEn,zEn); + bbmod->setExecutable(boxExecutable); + + bbmod->notifyObservers(_idManager); + + } + + + //========================================================================= + + int wxVtkSceneManager::createGBlackBox(int x, int y, std::string packageName, std::string boxType) + { + _worldState = NOTHING_HAPPENS; +//EED int windowWidth = _baseView->GetRenWin()->GetSize()[0]; + int windowHeight = _baseView->GetRenWin()->GetSize()[1]; + + int type = GBLACKBOX; //Create the MVC Objects - GBlackBoxModel *model = (GBlackBoxModel*)GObjectsMVCFactory::getInstance()->createGObjectModel(type); - vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type); - GObjectController* controller = GObjectsMVCFactory::getInstance()->createGObjectController(type); + GBlackBoxModel *model = (GBlackBoxModel*)GObjectsMVCFactory::getInstance()->createGObjectModel(type); + vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type); + GObjectController* controller = GObjectsMVCFactory::getInstance()->createGObjectController(type); - BlackBoxDescriptor::Pointer descriptor = GObjectsMVCFactory::getInstance()->getBlackBoxDescriptor(packageName, boxType); + BlackBoxDescriptor::Pointer descriptor = GObjectsMVCFactory::getInstance()->getBlackBoxDescriptor(packageName, boxType); //Prepares the initial model //The coordinates obtained are the following. Top-Left:x=0,y=0 Bottom-Right:x=width,y=height @@ -132,17 +180,14 @@ namespace bbtk _baseView->TransCoordScreenToWorld(xx,yy,zz); model->setInicPoint(xx,yy,zz); - _numBoxes++; std::stringstream stream; - if(_numBoxes<10) - { - stream << "Box0" << _numBoxes; - } - else - { - stream << "Box" << _numBoxes; - } + std::string newBoxName; + newBoxName = findANewNameForABox(); + + + stream << newBoxName; + std::string arraystring = stream.str(); model->setBBTKName(arraystring); @@ -190,6 +235,7 @@ namespace bbtk model->notifyObservers(_idManager); int newId = addObjectController(controller); + return newId; } @@ -198,24 +244,24 @@ namespace bbtk int wxVtkSceneManager::createGComplexBoxInputPort(std::string inputName) { - int windowWidth=_baseView->GetRenWin()->GetSize()[0]; +//EED int windowWidth=_baseView->GetRenWin()->GetSize()[0]; int windowHeight=_baseView->GetRenWin()->GetSize()[1]; - int type = GCOMPLEXINPUTPORT; + int type = GCOMPLEXINPUTPORT; //Create the MVC Objects - GComplexBoxPortModel *model = (GComplexBoxPortModel*)GObjectsMVCFactory::getInstance()->createGObjectModel(type); - vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type); - GObjectController* controller = GObjectsMVCFactory::getInstance()->createGObjectController(type); + GComplexBoxPortModel *model = (GComplexBoxPortModel*)GObjectsMVCFactory::getInstance()->createGObjectModel(type); + vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type); + GObjectController* controller = GObjectsMVCFactory::getInstance()->createGObjectController(type); //Prepares the initial model - double xx = 5; - double yy = windowHeight-5; + double xx = 5; + double yy = windowHeight-5; //z value is not important yet, because it is only used a parallel projection - double zz = 900; + double zz = 900; _baseView->TransCoordScreenToWorld(xx,yy,zz); model->setInicPoint(xx,yy,zz); @@ -251,24 +297,24 @@ namespace bbtk int wxVtkSceneManager::createGComplexBoxOutputPort(std::string outputName) { - int windowWidth=_baseView->GetRenWin()->GetSize()[0]; +//EED int windowWidth=_baseView->GetRenWin()->GetSize()[0]; int windowHeight=_baseView->GetRenWin()->GetSize()[1]; - int type = GCOMPLEXOUTPUTPORT; + int type = GCOMPLEXOUTPUTPORT; //Create the MVC Objects - GComplexBoxPortModel *model = (GComplexBoxPortModel*)GObjectsMVCFactory::getInstance()->createGObjectModel(type); - vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type); - GObjectController* controller = GObjectsMVCFactory::getInstance()->createGObjectController(type); + GComplexBoxPortModel *model = (GComplexBoxPortModel*)GObjectsMVCFactory::getInstance()->createGObjectModel(type); + vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type); + GObjectController* controller = GObjectsMVCFactory::getInstance()->createGObjectController(type); //Prepares the initial model - double xx = 5; - double yy = windowHeight-5; + double xx = 5; + double yy = windowHeight-5; //z value is not important yet, because it is only used a parallel projection - double zz = 900; + double zz = 900; _baseView->TransCoordScreenToWorld(xx,yy,zz); model->setInicPoint(xx,yy,zz); @@ -325,9 +371,9 @@ namespace bbtk int type = GPORT; //Create the MVC Objects - GPortModel *model = (GPortModel*)GObjectsMVCFactory::getInstance()->createGObjectModel(type); - vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type); - GObjectController* controller = GObjectsMVCFactory::getInstance()->createGObjectController(type); + GPortModel *model = (GPortModel*)GObjectsMVCFactory::getInstance()->createGObjectModel(type); + vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type); + GObjectController* controller = GObjectsMVCFactory::getInstance()->createGObjectController(type); model->registerInBox(blackBox,portType, posInBox); @@ -360,12 +406,12 @@ namespace bbtk int type = GCONNECTOR; manualConnectorContourController* manContourControl = new manualConnectorContourController(); - manualConnectorContourView* manContourView = new manualConnectorContourView(); - manualContourModel* manContourModel = new manualContourModel(); + manualConnectorContourView* manContourView = new manualConnectorContourView(); + manualContourModel* manContourModel = new manualContourModel(); - GConnectorController* connectorcontroller = new GConnectorController(); - GConnectorModel* connectorModel = new GConnectorModel(); - vtkGConnectorView* connectorView = new vtkGConnectorView(); + GConnectorController* connectorcontroller = new GConnectorController(); + GConnectorModel* connectorModel = new GConnectorModel(); + vtkGConnectorView* connectorView = new vtkGConnectorView(); connectorModel->setGObjectType(type); manContourModel->SetCloseContour(false); @@ -462,10 +508,10 @@ namespace bbtk { if(command == ADD_TO_SELECTED) { - GObjectController* cont = _controllers[idController]; +//EED GObjectController* cont = _controllers[idController]; bool foundID=false; - for (int i=0; i<_selectedObjects.size() && foundID==false; i++) + for (int i=0; i<(int)_selectedObjects.size() && foundID==false; i++) { int id = _selectedObjects[i]; if(id==idController) @@ -488,9 +534,11 @@ namespace bbtk // The last one is the controller of the connector - for(int i=0;i<_controllers.size();i++) + std::map::iterator it2; + + for(it2 = _controllers.begin(); it2 != _controllers.end(); ++it2) { - GObjectController* cont = _controllers[i]; + GObjectController *cont = it2->second; if(cont->getGObjectType() == GPORT ) { GPortModel* port = (GPortModel*)cont->getModel(); @@ -515,14 +563,14 @@ namespace bbtk _selectedObjects.clear(); - createGConnector(startOutputPort); + _idConnectionInCreation=createGConnector(startOutputPort); } else if(command == FIN_CREATION_CONTOUR && _worldState == INIT_CREATION_CONTOUR) { _worldState = NOTHING_HAPPENS; - int id = _controllers.size()-1; - GObjectController* cont = _controllers[id]; + //int id = _controllers.size()-1; + GObjectController* cont = _controllers[_idConnectionInCreation]; GConnectorModel* modelContour = (GConnectorModel*)cont->getModel(); GObjectController* finPort = _controllers[idController]; @@ -536,9 +584,11 @@ namespace bbtk manualConnectorContourView* connView = (manualConnectorContourView*)manCont->GetManualViewBaseContour(); connView->Refresh(); - for(int i=0;i<_controllers.size();i++) + std::map::iterator it2; + + for(it2 = _controllers.begin(); it2 != _controllers.end(); ++it2) { - GObjectController* cont = _controllers[i]; + GObjectController *cont = it2->second; if(cont->getView()!=NULL) { cont->getView()->setState(NOTHING_HAPPENS); @@ -563,7 +613,7 @@ namespace bbtk if(_worldState == DRAG_OBJECTS) { - for (int i=0; i<_selectedObjects.size(); i++) + for (int i=0; i<(int)_selectedObjects.size(); i++) { int id = _selectedObjects[i]; GObjectController* cont = _controllers[id]; @@ -641,11 +691,11 @@ namespace bbtk if(isOverPort==false) { _worldState=NOTHING_HAPPENS; - int lastId = _controllers.size()-1; - GConnectorController *connector = (GConnectorController*)_controllers[lastId]; + //int lastId = _controllers.size()-1; + GConnectorController *connector = (GConnectorController*)_controllers[_controllers.size()-1]; connector->removeFromScene(); unregisterController(connector); - _controllers.erase(lastId); + _controllers.erase(_controllers.size()-1); for(it = _controllers.begin(); it != _controllers.end(); ++it) { @@ -662,7 +712,7 @@ namespace bbtk _worldState = DRAG_OBJECTS; _startDragging = true; - for (int i = 0; i < _selectedObjects.size(); i++) + for (int i = 0; i < (int)_selectedObjects.size(); i++) { int id = _selectedObjects[i]; GObjectController* cont = _controllers[id]; @@ -684,7 +734,7 @@ namespace bbtk { _worldState = NOTHING_HAPPENS; - for (int i = 0; i < _selectedObjects.size(); i++) + for (int i = 0; i < (int)_selectedObjects.size(); i++) { int id = _selectedObjects[i]; GObjectController* cont = _controllers[id]; @@ -702,11 +752,11 @@ namespace bbtk if(_worldState==INIT_CREATION_CONTOUR) { _worldState=NOTHING_HAPPENS; - int lastId = _controllers.size()-1; - GConnectorController *connector = (GConnectorController*)_controllers[lastId]; + //int lastId = _controllers.size()-1; + GConnectorController *connector = (GConnectorController*)_controllers[_idConnectionInCreation]; connector->removeFromScene(); unregisterController(connector); - _controllers.erase(lastId); + _controllers.erase(_idConnectionInCreation); std::map::iterator it; for(it = _controllers.begin(); it != _controllers.end(); ++it) @@ -719,7 +769,7 @@ namespace bbtk } - for (int i = 0; i < _selectedObjects.size(); i++) + for (int i = 0; i < (int)_selectedObjects.size(); i++) { int id = _selectedObjects[i]; GObjectController* cont = _controllers[id]; @@ -755,7 +805,7 @@ namespace bbtk { if(type==GBLACKBOX) { - for (int i=0; i<_selectedObjects.size(); i++) + for (int i=0; i< (int)_selectedObjects.size(); i++) { int id = _selectedObjects[i]; GObjectController* control = _controllers[id]; @@ -790,10 +840,15 @@ namespace bbtk { if(_selectedObjects.size()>0) { - for(int i=0;i<_selectedObjects.size();i++) + for(int i=0;i<(int)_selectedObjects.size();i++) { - int id = _selectedObjects[i]; - deleteObject(id); + int id = _selectedObjects[i]; + std::map::iterator it; + it = _controllers.find(id); + if (it!=_controllers.end()) + { + deleteObject(id); + } } _selectedObjects.clear(); } @@ -804,6 +859,28 @@ namespace bbtk //========================================================================= + void wxVtkSceneManager::AddControlerToBeRemove(std::vector *controllersToRemove, int id) + { + + int i; + bool ok=true; + for(i=0 ; i < (int)controllersToRemove->size() ; i++ ) + { + if (id == (*controllersToRemove)[i] ) + { + ok=false; + } + } + + if (ok==true) + { + controllersToRemove->push_back( id ); + } + + } + + //========================================================================= + void wxVtkSceneManager::deleteObject(int id) { GObjectController *control = _controllers[id]; @@ -817,9 +894,9 @@ namespace bbtk bool boxConnected = false; // Add box input controllers to be removed - for(int i = 0;igetObjectId()); + AddControlerToBeRemove( &controllersToRemove, inputs[i]->getObjectId() ); if(inputs[i]->isConnected()) { boxConnected = true; @@ -829,9 +906,9 @@ namespace bbtk std::vector outputs = bbmod->getOutputPorts(); // Add box output controllers to be removed - for(int i = 0;igetObjectId()); + AddControlerToBeRemove( &controllersToRemove, outputs[i]->getObjectId() ); if(outputs[i]->isConnected()) { boxConnected = true; @@ -849,34 +926,39 @@ namespace bbtk GConnectorModel *conMod = (GConnectorModel*)cont->getModel(); if(conMod->getStartPort()!=NULL && conMod->getStartPort()->getParentBox()->getObjectId() == bbmod->getObjectId()) { - controllersToRemove.push_back(conMod->getObjectId()); + AddControlerToBeRemove( &controllersToRemove, conMod->getObjectId() ); } if(conMod->getEndPort()!=NULL && conMod->getEndPort()->getParentBox()->getObjectId() == bbmod->getObjectId()) { - controllersToRemove.push_back(conMod->getObjectId()); + AddControlerToBeRemove( &controllersToRemove, conMod->getObjectId() ); } } } // Add box controller to be removed - controllersToRemove.push_back(bbmod->getObjectId()); + AddControlerToBeRemove( &controllersToRemove, bbmod->getObjectId() ); } else if(control->getGObjectType()==GCONNECTOR) { GConnectorModel *conMod = (GConnectorModel*)control->getModel(); - controllersToRemove.push_back(conMod->getObjectId()); - } - - for(int i = 0;iremoveFromScene(); - unregisterController((InteractorStyleMaracas*)cont); - _controllers.erase(id); + AddControlerToBeRemove( &controllersToRemove, conMod->getObjectId() ); } + + std::map::iterator it; + for(int i = 0;i<(int)controllersToRemove.size();i++) + { + int key = controllersToRemove[i]; + it = _controllers.find( key ); + GObjectController *cont = _controllers[ key ]; + if(cont!=NULL) + { + cont->removeFromScene(); + unregisterController((InteractorStyleMaracas*)cont); + _controllers.erase(it); + }//if + }// for } //========================================================================= @@ -917,7 +999,7 @@ namespace bbtk std::string pkg = mod->getBBTKPackage(); bool existsPkg = false; - for(int t = 0;t inputs = model->getInputPorts(); - for(int j = 0; jisValueSet()) @@ -990,7 +1072,7 @@ namespace bbtk } - for(i = 0; igetBBTKPackage(); bool existsPkg = false; - for(int t = 0;t inputs = model->getInputPorts(); - for(int j = 0; jisValueSet()) { - script+="set "; + script+=" set "; script+=model->getBBTKName(); script+="."; script+=inputPort->getBBTKName(); @@ -1131,6 +1216,7 @@ namespace bbtk script+="\n"; } } + script+="\n"; } @@ -1138,8 +1224,9 @@ namespace bbtk std::string complexInputs=""; std::string complexOutputs=""; + script+="\n"; - for(i = 0; igetModel()->save(content); } - } + } // _isComplexBox else { content+="FALSE\n"; @@ -1370,7 +1459,7 @@ namespace bbtk //---------- getline(inputStream,line);//COMPLEX_BOX:TRUE|FALSE - char complex[15]; + char complex[30]; strcpy( complex, line.c_str() ); result = strtok( complex, delims ); result = strtok( NULL, delims ); @@ -1384,7 +1473,7 @@ namespace bbtk //- COMPLEX INPUT PORTS //----------------------- getline(inputStream,line);//COMPLEXINPUTS:num - char inputs[18]; + char inputs[30]; strcpy( inputs, line.c_str() ); result = strtok( inputs, delims ); result = strtok( NULL, delims ); @@ -1426,7 +1515,7 @@ namespace bbtk GBoxModel *cbmod = (GBoxModel*)cont->getModel(); cbmod->setInicPoint(xIn,yIn,zIn); cbmod->notifyObservers(_idManager); - } + } // for input complex box //----------------------- @@ -1434,7 +1523,7 @@ namespace bbtk //----------------------- getline(inputStream,line);//COMPLEXOUTPUTS:num - char outputs[18]; + char outputs[30]; strcpy( outputs, line.c_str() ); result = strtok( outputs, delims ); result = strtok( NULL, delims ); @@ -1471,14 +1560,15 @@ namespace bbtk getline(inputStream,line);//FIN_COMPLEX_PORT + int idOutputPort = createGComplexBoxOutputPort(outputPortName); GObjectController *cont = _controllers[idOutputPort]; GBoxModel *cbmod = (GBoxModel*)cont->getModel(); cbmod->setInicPoint(xIn,yIn,zIn); cbmod->notifyObservers(_idManager); - } + } // for output complex box - } + } // complex box //---------- getline(inputStream,line);//BOXES:num @@ -1496,7 +1586,7 @@ namespace bbtk //---------- getline(inputStream,line);//BOX getline(inputStream,line);//package:type:name - char box[100]; + char box[150]; strcpy( box, line.c_str() ); result = strtok( box, delims );//package std::string package(result); @@ -1549,20 +1639,27 @@ namespace bbtk 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); + bool boxExecutable=false; if(isExec=="TRUE") { - bbmod->setExecutable(true); - } - else if(isExec=="FALSE") - { - bbmod->setExecutable(false); + boxExecutable= true; } + + int idBox = createGBlackBox(xIn,yIn,package,type); + configGBlackBox(idBox, xIn,yIn,zIn,name, boxExecutable,xEn,yEn,zEn); + + GObjectController *cont = _controllers[idBox]; + GBlackBoxModel *bbmod = (GBlackBoxModel*)cont->getModel(); + + +//ups2 eed +// GObjectController *cont = _controllers[idBox]; +// GBlackBoxModel *bbmod = (GBlackBoxModel*)cont->getModel(); +// bbmod->setBBTKName(name); +// bbmod->setInicPoint(xIn,yIn,zIn); +// bbmod->setFinalPoint(xEn,yEn,zEn); +// bbmod->setExecutable(boxExecutable); + //---------- getline(inputStream,line);//PORT o FIN_BOX @@ -1570,7 +1667,7 @@ namespace bbtk while(port=="PORT") { getline(inputStream,line);//name:value - char poort[20]; + char poort[150]; strcpy( poort, line.c_str() ); result = strtok( poort, delims );//name std::string name(result); @@ -1581,15 +1678,15 @@ namespace bbtk getline(inputStream,line);//PORT o FIN_BOX port=line.substr(0,4); - } + } // while - bbmod->notifyObservers(_idManager); - } +//EED bbmod->notifyObservers(_idManager); + } // boxes /// CONNECTIONS //---------- getline(inputStream,line);//CONNECTIONS:num - char conns[15]; + char conns[30]; strcpy( conns, line.c_str() ); result = strtok( conns, delims ); result = strtok( NULL, delims ); @@ -1604,7 +1701,7 @@ namespace bbtk getline(inputStream,line);//CONNECTION getline(inputStream,line);//Startbox.PortName:EndBox.PortName - char connec[100]; + char connec[200]; strcpy( connec, line.c_str() ); result = strtok( connec, delims ); std::string nameStartBox(result); @@ -1615,11 +1712,14 @@ namespace bbtk result = strtok( NULL, delims ); std::string nameEndPort(result); - std::vector lstB = getBlackBoxes(); - - GPortModel *startP=NULL; - GPortModel *endP=NULL; - for(int j = 0;j lstB = getBlackBoxes(); + GPortModel *startP = NULL; + GPortModel *endP = NULL; + int j; + for(j = 0;jgetModel(); @@ -1631,38 +1731,38 @@ namespace bbtk { endP = bbMod->getInputPort(nameEndPort); } - } + } // for if(_isComplexBox) { if(startP==NULL) { std::vector lstInputs = getComplexInputPorts(); - for(int j = 0;jgetModel(); if(_controllers[idB]->getModel()->getBBTKName()==nameStartBox) { startP = cbMod->getOutputPort(nameStartPort); - } - } - } + } // if + } // for + } // if if(endP==NULL) { std::vector lstOutputs = getComplexOutputPorts(); - for(int j = 0;jgetModel(); if(_controllers[idB]->getModel()->getBBTKName()==nameEndBox) { endP = cbMod->getInputPort(nameEndPort); - } - } - } - } + } // if + } // for + } // if endP + } // complex box int idCon = createGConnector(startP); _worldState = NOTHING_HAPPENS; @@ -1673,10 +1773,119 @@ namespace bbtk tempp->endContourCreation(); conMod->setEndPort(endP); conView->updateStartEndPoints(); + */ + } // for numConns + + } // start + } + + //========================================================================= + + GBlackBoxModel* wxVtkSceneManager::findGBox(std::string boxname) + { + GBlackBoxModel *boxModel = NULL; + GBlackBoxModel *bbMod; + std::vector lstB = getBlackBoxes(); + int idB; + int j; + for(j = 0;j<(int)lstB.size();j++) + { + idB = lstB[j]; + bbMod = (GBlackBoxModel*)_controllers[idB]->getModel(); + if(_controllers[idB]->getModel()->getBBTKName()==boxname) + { + boxModel = bbMod; } - } + } // for + return boxModel; + } + + //========================================================================= + + + void wxVtkSceneManager::configGConnetion(bool _isComplexBox, + std::string nameStartBox, std::string nameStartPort, std::string + nameEndBox, std::string nameEndPort) + { + GPortModel *startP = findGBox(nameStartBox)->getOutputPort(nameStartPort); + GPortModel *endP = findGBox(nameEndBox)->getInputPort(nameEndPort); + +/*ups5 EED Borrame + std::vector lstB = getBlackBoxes(); + int j; + for(j = 0;j<(int)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); + } + } // for +*/ + int j; + if(_isComplexBox) + { + if(startP==NULL) + { + std::vector lstInputs = getComplexInputPorts(); + for(j = 0;j<(int)lstInputs.size();j++) + { + int idB = lstInputs[j]; + GBoxModel *cbMod = (GBoxModel*)_controllers[idB]->getModel(); + if(_controllers[idB]->getModel()->getBBTKName()==nameStartBox) + { + startP = cbMod->getOutputPort(nameStartPort); + } // if + } // for + } // if + + if(endP==NULL) + { + std::vector lstOutputs = getComplexOutputPorts(); + for(j = 0;j<(int)lstOutputs.size();j++) + { + int idB = lstOutputs[j]; + GBoxModel *cbMod = (GBoxModel*)_controllers[idB]->getModel(); + if(_controllers[idB]->getModel()->getBBTKName()==nameEndBox) + { + endP = cbMod->getInputPort(nameEndPort); + } // if + } // for + } // if endP + } // complex box + + 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(); + } + //========================================================================= + + bool wxVtkSceneManager::boxExist(std::string boxname) + { + bool ok=false; + std::map::iterator it; + for(it = _controllers.begin(); it != _controllers.end(); ++it) + { + GObjectController *cont = it->second; + if(cont->getModel()->getBBTKName()==boxname) + { + ok=true; + } + } + return ok; } //========================================================================= @@ -1760,7 +1969,7 @@ namespace bbtk { _isComplexBox=val; } - + //========================================================================= int wxVtkSceneManager::addObjectController(GObjectController* objController) @@ -1769,9 +1978,10 @@ namespace bbtk registerController((InteractorStyleMaracas*) objController); //Add the object to the objects list - int newId = _controllers.size(); + int newId = _contLastId;//_controllers.size(); objController->setId(newId); _controllers[newId] = objController; + _contLastId++; return newId; } @@ -1911,11 +2121,11 @@ namespace bbtk std::vector newInputConnections = newBox->getConnectedInputs(); std::vector newOutputConnections = newBox->getConnectedOutputs(); - for(int k = 0; k