X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=lib%2FEditorGraphicBBS%2FbbsKernelEditorGraphic%2FwxVtkSceneManager.cxx;h=902db263402a2189e8e5190bb88de0d80f14063f;hb=66d85963bdb3dea88f7d8e8931855d092629b37c;hp=4fcb0434e0c6ca4fa0125b12fafc068850fe9235;hpb=e36858ea5937bb1699bc437136718007df27be7b;p=bbtkGEditor.git diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx index 4fcb043..902db26 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx @@ -43,14 +43,17 @@ namespace bbtk //========================================================================= wxVtkSceneManager::wxVtkSceneManager(wxGEditorTabPanel *parent, wxVtk3DBaseView *baseView,int idManager) { + printf ("EED %p wxVtkSceneManager()\n" , this ); _parent = parent; _numBoxes=0; _idManager=idManager; _baseView=baseView; _startDragging=false; + _isComplexBox=false; if( _baseView!=NULL ) { +//EED02JUIN2010 _baseView->GetWxVTKRenderWindowInteractor()->SetDropTarget((wxDropTarget*)parent); configureBaseView(); _worldState=NOTHING_HAPPENS; @@ -64,15 +67,19 @@ namespace bbtk void wxVtkSceneManager::disconnectDrop() { - _baseView->GetWxVTKRenderWindowInteractor()->SetDropTarget(NULL); - } + printf ("EED %p ~wxVtkSceneManager::disconnectDrop()\n" , this ); +//EED02JUIN2010 _baseView->GetWxVTKRenderWindowInteractor()->SetDropTarget(NULL); +// _baseView->GetWxVTKRenderWindowInteractor()->SetDropTarget( new tmpClasswxTextDropTarget() ); + } //========================================================================= wxVtkSceneManager::~wxVtkSceneManager() { + printf ("EED %p ~wxVtkSceneManager()\n" , this ); + disconnectDrop(); } - + //========================================================================= void wxVtkSceneManager::configureBaseView() @@ -99,7 +106,6 @@ namespace bbtk int wxVtkSceneManager::createGBlackBox(int x, int y, std::string packageName, std::string boxType) { - int windowWidth=_baseView->GetRenWin()->GetSize()[0]; int windowHeight=_baseView->GetRenWin()->GetSize()[1]; @@ -182,20 +188,120 @@ namespace bbtk //Resgiter change to the observers of the actual model model->notifyObservers(_idManager); - //Register the controller of the new object - registerController((InteractorStyleMaracas*) controller); + int newId = addObjectController(controller); + return newId; - //Add the object to the objects list - int newId = _controllers.size(); - controller->setId(newId); - _controllers[newId] = controller; + } + + //========================================================================= + + int wxVtkSceneManager::createGComplexBoxInputPort(std::string inputName) + { + int windowWidth=_baseView->GetRenWin()->GetSize()[0]; + int windowHeight=_baseView->GetRenWin()->GetSize()[1]; + + 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); + + //Prepares the initial model + + double xx = 5; + double yy = windowHeight-5; + + //z value is not important yet, because it is only used a parallel projection + double zz = 900; + + _baseView->TransCoordScreenToWorld(xx,yy,zz); + model->setInicPoint(xx,yy,zz); + + model->setBBTKName(inputName); + model->setBBTKType("ComplexInputPort"); + model->setComplexPortType(type); + + model->addObserver(view); + model->addObserver(this); + + //create the output port + GPortController* portController = createGPort(GOUTPUTPORT,inputName,"ComplexInputPort",0,model); + model->addOutputPort((GPortModel*)portController->getModel()); + + //Associates the view with the correspondent renderer and the model. + //(NOTE: Refresh is only made by the view) + view->setModel(model); + view->setBaseView(_baseView); + view->initVtkObjects(); + + //Associates the controller with the correspondent model and view + controller->setModelAndView(model,view); + + //Resgiter change to the observers of the actual model + model->notifyObservers(_idManager); + + int newId = addObjectController(controller); return newId; + } + + //========================================================================= + + int wxVtkSceneManager::createGComplexBoxOutputPort(std::string outputName) + { + int windowWidth=_baseView->GetRenWin()->GetSize()[0]; + int windowHeight=_baseView->GetRenWin()->GetSize()[1]; + 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); + + //Prepares the initial model + + double xx = 5; + double yy = windowHeight-5; + + //z value is not important yet, because it is only used a parallel projection + double zz = 900; + + _baseView->TransCoordScreenToWorld(xx,yy,zz); + model->setInicPoint(xx,yy,zz); + + model->setBBTKName(outputName); + model->setBBTKType("ComplexOutputPort"); + model->setComplexPortType(type); + + model->addObserver(view); + model->addObserver(this); + + //create the output port + GPortController* portController = createGPort(GINPUTPORT,outputName,"ComplexInputPort",0,model); + model->addInputPort((GPortModel*)portController->getModel()); + + //Associates the view with the correspondent renderer and the model. + //(NOTE: Refresh is only made by the view) + view->setModel(model); + view->setBaseView(_baseView); + view->initVtkObjects(); + + //Associates the controller with the correspondent model and view + controller->setModelAndView(model,view); + + //Resgiter change to the observers of the actual model + model->notifyObservers(_idManager); + + int newId = addObjectController(controller); + return newId; } //========================================================================= - int wxVtkSceneManager::createGInputPort(int portType, int posinBox,GBlackBoxModel *blackBox, BlackBoxInputDescriptor *desc) + int wxVtkSceneManager::createGInputPort(int portType, int posinBox,GBoxModel *blackBox, BlackBoxInputDescriptor *desc) { GPortController* portController = createGPort(portType,desc->GetName(),desc->GetTypeName(),posinBox,blackBox); blackBox->addInputPort((GPortModel*)portController->getModel()); @@ -204,7 +310,7 @@ namespace bbtk //========================================================================= - int wxVtkSceneManager::createGOutputPort(int portType, int posinBox,GBlackBoxModel *blackBox, BlackBoxOutputDescriptor *desc) + int wxVtkSceneManager::createGOutputPort(int portType, int posinBox,GBoxModel *blackBox, BlackBoxOutputDescriptor *desc) { GPortController* portController = createGPort(portType,desc->GetName(),desc->GetTypeName(),posinBox,blackBox); blackBox->addOutputPort((GPortModel*)portController->getModel()); @@ -213,7 +319,7 @@ namespace bbtk //========================================================================= - GPortController* wxVtkSceneManager::createGPort(int portType,std::string bbtkName, std::string bbtkType, int posInBox,GBlackBoxModel *blackBox) + GPortController* wxVtkSceneManager::createGPort(int portType,std::string bbtkName, std::string bbtkType, int posInBox,GBoxModel *blackBox) { int type = GPORT; @@ -241,12 +347,7 @@ namespace bbtk model->notifyObservers(_idManager); - //Register the controller of the new object - registerController((InteractorStyleMaracas*) controller); - - int newId = _controllers.size(); - controller->setId(newId); - _controllers[newId] = controller; + int newId = addObjectController(controller); return (GPortController*)controller; } @@ -263,7 +364,7 @@ namespace bbtk GConnectorController* connectorcontroller = new GConnectorController(); GConnectorModel* connectorModel = new GConnectorModel(); - GConnectorView* connectorView = new GConnectorView(); + vtkGConnectorView* connectorView = new vtkGConnectorView(); connectorModel->setGObjectType(type); manContourModel->SetCloseContour(false); @@ -305,22 +406,20 @@ namespace bbtk manContourControl->SetMoving( false ); - registerController((InteractorStyleMaracas*) connectorcontroller); + connectorcontroller->setModelAndView(connectorModel,connectorView); + + int newId = addObjectController(connectorcontroller); connectorcontroller->setManualContourController(manContourControl); connectorModel->setManualContourModel(manContourModel); connectorView->setManualContourView(manContourView); connectorView->setModel(connectorModel); connectorView->setBaseView(_baseView); - connectorcontroller->setModelAndView(connectorModel,connectorView); + connectorModel->addObserver(connectorView); connectorModel->addObserver(this); - int newId = _controllers.size(); - connectorcontroller->setId(newId); - _controllers[newId] = connectorcontroller; - return newId; } @@ -483,7 +582,7 @@ namespace bbtk GObjectController *desc = it->second; if(desc->getGObjectType()==GCONNECTOR) { - GConnectorView* vconn = (GConnectorView*)desc->getView(); + vtkGConnectorView* vconn = (vtkGConnectorView*)desc->getView(); vconn->updateStartEndPoints(); } } @@ -513,9 +612,6 @@ namespace bbtk } } - - - return true; } @@ -712,9 +808,9 @@ namespace bbtk GObjectController *control = _controllers[id]; std::vector controllersToRemove; - if(control->getGObjectType()==GBLACKBOX) + if(control->getGObjectType()==GBLACKBOX || control->getGObjectType()==GCOMPLEXINPUTPORT || control->getGObjectType()==GCOMPLEXOUTPUTPORT) { - GBlackBoxModel *bbmod = (GBlackBoxModel*)control->getModel(); + GBoxModel *bbmod = (GBoxModel*)control->getModel(); std::vector inputs = bbmod->getInputPorts(); bool boxConnected = false; @@ -767,7 +863,6 @@ namespace bbtk else if(control->getGObjectType()==GCONNECTOR) { GConnectorModel *conMod = (GConnectorModel*)control->getModel(); - cout<<"RaC wxVtkSceneManager::deleteObject id:"<getObjectId()<getObjectId()); } @@ -799,7 +894,7 @@ namespace bbtk //========================================================================= - std::string wxVtkSceneManager::getDiagramScript() + std::string wxVtkSceneManager::getDiagramBBS() { bool existsExec=false; @@ -934,6 +1029,201 @@ namespace bbtk //========================================================================= + std::string wxVtkSceneManager::saveComplexBoxBBS(std::string cbName,std::string cbAuthor,std::string cbCategory,std::string cbDescription) + { + + std::vector packages; + std::vector boxes; + std::vector connections; + std::vector execBoxes; + + std::map::iterator it; + + for(it = _controllers.begin(); it != _controllers.end(); ++it) + { + GObjectController *desc = it->second; + int type = desc->getGObjectType(); + + if(type==GBLACKBOX) + { + GBlackBoxModel *mod = (GBlackBoxModel*)desc->getModel(); + + std::string pkg = mod->getBBTKPackage(); + bool existsPkg = false; + for(int t = 0;tfirst); + if(mod->isExecutable()) + { + execBoxes.push_back(it->first); + } + } + else if(type==GCONNECTOR) + { + connections.push_back(it->first); + } + } + + std::string script = ""; + int i; + for(i = 0; igetModel(); + + script+=model->getBBTKType(); + script+=" "; + script+=model->getBBTKName(); + script+="\n"; + + std::vector inputs = model->getInputPorts(); + for(int j = 0; jisValueSet()) + { + script+="set "; + script+=model->getBBTKName(); + script+="."; + script+=inputPort->getBBTKName(); + script+=" "; + script+=inputPort->getValue(); + script+="\n"; + } + } + + } + + // Create connections in the script. If the connection is made with a complex port, it is created the input or output + + std::string complexInputs=""; + std::string complexOutputs=""; + + for(i = 0; igetModel(); + + //Connection info + GPortModel *start = model->getStartPort(); + GBoxModel *startBox =start->getParentBox(); + + GPortModel *end = model->getEndPort(); + GBoxModel *endBox =end->getParentBox(); + + if(startBox->getGObjectType()==GCOMPLEXINPUTPORT) + { + complexInputs+="input "; + complexInputs+=startBox->getBBTKName(); + + complexInputs+=" "; + complexInputs+=endBox->getBBTKName(); + complexInputs+="."; + complexInputs+=end->getBBTKName(); + + complexInputs+=" "; + complexInputs+="\" \""; + + complexInputs+="\n"; + } + else if(endBox->getGObjectType()==GCOMPLEXOUTPUTPORT) + { + complexOutputs+="output "; + complexOutputs+=endBox->getBBTKName(); + + complexOutputs+=" "; + complexOutputs+=startBox->getBBTKName(); + complexOutputs+="."; + complexOutputs+=start->getBBTKName(); + + complexOutputs+=" "; + complexOutputs+="\" \""; + + complexOutputs+="\n"; + } + else + { + script+="connect "; + script+=startBox->getBBTKName(); + script+="."; + script+=start->getBBTKName(); + + script+=" "; + + //End Connection info + script+=endBox->getBBTKName(); + script+="."; + script+=end->getBBTKName(); + + script+="\n"; + } + } + + for(i = 0; igetModel(); + + script+=model->getBBTKName(); + script+="\n"; + } + + script+="\n"; + script+="# Complex input ports\n"; + script+=complexInputs; + + script+="\n"; + script+="# Complex output ports\n"; + script+=complexOutputs; + + script+="\n"; + script+="endefine"; + script+="\n"; + + return script; + } + + //========================================================================= + void wxVtkSceneManager::deleteAllBoxes() { std::map::iterator it; @@ -971,10 +1261,52 @@ namespace bbtk //========================================================================= void wxVtkSceneManager::saveDiagram(std::string &content) - { - //Print boxes + { char buffer [50]; - std::vector boxes = getBoxes(); + + //Print info IF COMPLEX BOX + content+="COMPLEXBOX:"; + if(_isComplexBox) + { + content+="TRUE\n"; + + //Print info complex input ports + std::vector inputs = getComplexInputPorts(); + int insize = inputs.size(); + content+="COMPLEXINPUTS:"; + sprintf (buffer, "%d", insize); + content+=buffer; + content+="\n"; + + for(int i = 0;igetModel()->save(content); + } + + //Print info complex output ports + std::vector outputs = getComplexOutputPorts(); + int outsize = outputs.size(); + content+="COMPLEXOUTPUTS:"; + sprintf (buffer, "%d", outsize); + content+=buffer; + content+="\n"; + + for(int i = 0;igetModel()->save(content); + } + } + else + { + content+="FALSE\n"; + } + + //Print boxes + std::vector boxes = getBlackBoxes(); int bsize = boxes.size(); content+="BOXES:"; sprintf (buffer, "%d", bsize); @@ -1031,6 +1363,119 @@ namespace bbtk if(start) { + + //---------- + getline(inputStream,line);//COMPLEX_BOX:TRUE|FALSE + char complex[15]; + strcpy( complex, line.c_str() ); + result = strtok( complex, delims ); + result = strtok( NULL, delims ); + std::string isComplexBox(result); + + if(isComplexBox=="TRUE") + { + _isComplexBox=true; + + //----------------------- + //- COMPLEX INPUT PORTS + //----------------------- + getline(inputStream,line);//COMPLEXINPUTS:num + char inputs[18]; + strcpy( inputs, line.c_str() ); + result = strtok( inputs, delims ); + result = strtok( NULL, delims ); + + int numInputs; + std::istringstream inps(result); + inps >> numInputs; + + for(int i = 0;i> xIn; + std::istringstream ySt(yInic); + ySt >> yIn; + std::istringstream zSt(zInic); + zSt >> zIn; + + getline(inputStream,line);//FIN_COMPLEX_PORT + + int idInputPort = createGComplexBoxInputPort(inputPortName); + GObjectController *cont = _controllers[idInputPort]; + GBoxModel *cbmod = (GBoxModel*)cont->getModel(); + cbmod->setInicPoint(xIn,yIn,zIn); + cbmod->notifyObservers(_idManager); + } + + + //----------------------- + //- COMPLEX OUTPUT PORTS + //----------------------- + + getline(inputStream,line);//COMPLEXOUTPUTS:num + char outputs[18]; + strcpy( outputs, line.c_str() ); + result = strtok( outputs, delims ); + result = strtok( NULL, delims ); + + int numOutputs; + std::istringstream outps(result); + outps >> numOutputs; + + for(int i = 0;i> xIn; + std::istringstream ySt(yInic); + ySt >> yIn; + std::istringstream zSt(zInic); + zSt >> zIn; + + 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); + } + + } + //---------- getline(inputStream,line);//BOXES:num char boxes[9]; @@ -1056,6 +1501,13 @@ namespace bbtk 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]; @@ -1099,9 +1551,17 @@ namespace bbtk 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 + getline(inputStream,line);//PORT o FIN_BOX std::string port=line.substr(0,4); while(port=="PORT") { @@ -1151,7 +1611,7 @@ namespace bbtk result = strtok( NULL, delims ); std::string nameEndPort(result); - std::vector lstB = getBoxes(); + std::vector lstB = getBlackBoxes(); GPortModel *startP=NULL; GPortModel *endP=NULL; @@ -1168,13 +1628,44 @@ namespace bbtk endP = bbMod->getInputPort(nameEndPort); } } - + + 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(endP==NULL) + { + std::vector lstOutputs = getComplexOutputPorts(); + for(int j = 0;jgetModel(); + if(_controllers[idB]->getModel()->getBBTKName()==nameEndBox) + { + endP = cbMod->getInputPort(nameEndPort); + } + } + } + } + int idCon = createGConnector(startP); _worldState = NOTHING_HAPPENS; GConnectorController *tempp = (GConnectorController*)_controllers[idCon]; GConnectorModel *conMod = (GConnectorModel*)tempp->getModel(); - GConnectorView *conView = (GConnectorView*)tempp->getView(); + vtkGConnectorView *conView = (vtkGConnectorView*)tempp->getView(); tempp->endContourCreation(); conMod->setEndPort(endP); conView->updateStartEndPoints(); @@ -1186,7 +1677,7 @@ namespace bbtk //========================================================================= - std::vector wxVtkSceneManager::getBoxes() + std::vector wxVtkSceneManager::getBlackBoxes() { std::vector vect; std::map::iterator it; @@ -1203,6 +1694,40 @@ namespace bbtk //========================================================================= + std::vector wxVtkSceneManager::getComplexInputPorts() + { + std::vector vect; + std::map::iterator it; + for(it = _controllers.begin(); it != _controllers.end(); ++it) + { + GObjectController *cont = it->second; + if(cont->getGObjectType()==GCOMPLEXINPUTPORT) + { + vect.push_back(cont->getId()); + } + } + return vect; + } + + //========================================================================= + + std::vector wxVtkSceneManager::getComplexOutputPorts() + { + std::vector vect; + std::map::iterator it; + for(it = _controllers.begin(); it != _controllers.end(); ++it) + { + GObjectController *cont = it->second; + if(cont->getGObjectType()==GCOMPLEXOUTPUTPORT) + { + vect.push_back(cont->getId()); + } + } + return vect; + } + + //========================================================================= + std::vector wxVtkSceneManager::getConnections() { std::vector vect; @@ -1219,6 +1744,260 @@ namespace bbtk } //========================================================================= + + bool wxVtkSceneManager::isComplexBox() + { + return _isComplexBox; + } + + //========================================================================= + + void wxVtkSceneManager::setComplexBox(bool val) + { + _isComplexBox=val; + } + + //========================================================================= + + int wxVtkSceneManager::addObjectController(GObjectController* objController) + { + //Register the controller of the new object + registerController((InteractorStyleMaracas*) objController); + + //Add the object to the objects list + int newId = _controllers.size(); + objController->setId(newId); + _controllers[newId] = objController; + return newId; + } + + //========================================================================= + + int wxVtkSceneManager::getNumSelectedObjects() + { + return _selectedObjects.size(); + } + + //========================================================================= + + std::map wxVtkSceneManager::getSelectedObjects() + { + std::map mapSelected; + + std::map::iterator it; + for(it = _controllers.begin(); it != _controllers.end(); ++it) + { + GObjectController *cont = it->second; + if(cont->getGObjectType()==GBLACKBOX && cont->getView()->getState()==SELECTED) + { + mapSelected[cont->getId()]=cont; + } + } + + std::map::iterator it2; + for(it2 = _controllers.begin(); it2 != _controllers.end(); ++it2) + { + GObjectController *cont = it2->second; + if(cont->getGObjectType()==GCONNECTOR) + { + GConnectorModel* cmod = (GConnectorModel*)cont->getModel(); + GBoxModel* endPortParentBox = cmod->getEndPort()->getParentBox(); + GBoxModel* startPortParentBox = cmod->getStartPort()->getParentBox(); + + std::map::iterator iterOBJ1 = mapSelected.find(startPortParentBox->getObjectId()); + std::map::iterator iterOBJ2 = mapSelected.find(endPortParentBox->getObjectId()); + + if(iterOBJ1 != mapSelected.end() && iterOBJ2 != mapSelected.end()) + { + int ID = cont->getId(); + mapSelected[ID]=cont; + } + + } + } + return mapSelected; + } + + //========================================================================= + + void wxVtkSceneManager::addObjects(std::map objectsMap) + { + + std::map oldIdNewIdBoxes; + std::vector connections; + + std::map::iterator it; + for(it = objectsMap.begin(); it != objectsMap.end(); ++it) + { + GObjectController *cont = it->second; + int type = cont->getGObjectType(); + + if(type==GBLACKBOX) + { + // Copy black box + double xInic, yInic,zInic; + GBlackBoxModel* copyBox = (GBlackBoxModel*)cont->getModel(); + copyBox->getInicPoint(xInic,yInic,zInic); + int idBox = createGBlackBox(0,0,copyBox->getBBTKPackage(),copyBox->getBBTKType()); + + int idcB = copyBox->getObjectId(); + oldIdNewIdBoxes[idcB]=idBox; + cont = _controllers[idBox]; + GBlackBoxModel* newbox = (GBlackBoxModel*)cont->getModel(); + newbox->setInicPoint(xInic,yInic,zInic); + int num = newbox->getNumInputPorts(); + for(int j=0;jsetValueToInputPort(j,copyBox->getValueInputPort(j)); + } + newbox->notifyObservers(_idManager); + } + else if(type==GCONNECTOR) + { + int idCon = cont->getId(); + connections.push_back(idCon); + } + + } + + for(int i = 0 ;igetModel(); + + GPortModel* startPort = connectModel->getStartPort(); + int startPortIndex = startPort->getPosInBox(); + GPortModel* endPort = connectModel->getEndPort(); + int endPortIndex = endPort->getPosInBox(); + + GBlackBoxModel* startPortParentBox = (GBlackBoxModel*)startPort->getParentBox(); + GBlackBoxModel* endPortParentBox = (GBlackBoxModel*)endPort->getParentBox(); + + int idNewStartBox = oldIdNewIdBoxes[startPortParentBox->getObjectId()]; + int idNewEndBox = oldIdNewIdBoxes[endPortParentBox->getObjectId()]; + + GBlackBoxModel* newStartBox = (GBlackBoxModel*)_controllers[idNewStartBox]->getModel(); + GBlackBoxModel* newEndBox = (GBlackBoxModel*)_controllers[idNewEndBox]->getModel(); + + GPortModel* newStartPort = newStartBox->getOutputPort(startPortIndex); + GPortModel* newEndPort = newEndBox->getInputPort(endPortIndex); + + // Creates connection + int idCon = createGConnector(newStartPort); + GConnectorController *tempp = (GConnectorController*)_controllers[idCon]; + GConnectorModel *conMod = (GConnectorModel*)tempp->getModel(); + vtkGConnectorView *conView = (vtkGConnectorView*)tempp->getView(); + tempp->endContourCreation(); + conMod->setEndPort(newEndPort); + conView->updateStartEndPoints(); + } + + std::map::iterator itIds; + for(itIds = oldIdNewIdBoxes.begin(); itIds != oldIdNewIdBoxes.end(); ++itIds) + { + int idOld = itIds->first; + int idNew = itIds->second; + + GBlackBoxModel* oldBox = (GBlackBoxModel*)objectsMap[idOld]->getModel(); + GBlackBoxModel* newBox = (GBlackBoxModel*)_controllers[idNew]->getModel(); + + std::vector oldInputConnections = oldBox->getConnectedInputs(); + std::vector oldOutputConnections = oldBox->getConnectedOutputs(); + std::vector newInputConnections = newBox->getConnectedInputs(); + std::vector newOutputConnections = newBox->getConnectedOutputs(); + + for(int k = 0; kgetInputPort(posInBox); + std::string inputPortName = inputPort->getBBTKName(); + int idInputPort = createGComplexBoxInputPort(inputPortName); + GObjectController *cont = _controllers[idInputPort]; + GBoxModel *cbmod = (GBoxModel*)cont->getModel(); + double xIn,yIn,zIn; + inputPort->getInicPoint(xIn,yIn,zIn); + yIn+=20; + cbmod->setInicPoint(xIn,yIn,zIn); + cbmod->notifyObservers(_idManager); + + GPortModel* inputPortEnd = newBox->getInputPort(posInBox); + + // Creates connection + int idCon = createGConnector(cbmod->getOutputPort(0)); + GConnectorController *tempp = (GConnectorController*)_controllers[idCon]; + GConnectorModel *conMod = (GConnectorModel*)tempp->getModel(); + vtkGConnectorView *conView = (vtkGConnectorView*)tempp->getView(); + tempp->endContourCreation(); + conMod->setEndPort(inputPortEnd); + conView->updateStartEndPoints(); + + } + + } + + + for(int k = 0; kgetOutputPort(posInBox); + std::string outputPortName = outputPort->getBBTKName(); + int idOutputPort = createGComplexBoxOutputPort(outputPortName); + GObjectController *cont = _controllers[idOutputPort]; + GBoxModel *cbmod = (GBoxModel*)cont->getModel(); + double xIn,yIn,zIn; + outputPort->getInicPoint(xIn,yIn,zIn); + yIn-=20; + cbmod->setInicPoint(xIn,yIn,zIn); + cbmod->notifyObservers(_idManager); + + GPortModel* outputPortEnd = newBox->getOutputPort(posInBox); + + // Creates connection + int idCon = createGConnector(outputPortEnd); + GConnectorController *tempp = (GConnectorController*)_controllers[idCon]; + GConnectorModel *conMod = (GConnectorModel*)tempp->getModel(); + vtkGConnectorView *conView = (vtkGConnectorView*)tempp->getView(); + tempp->endContourCreation(); + conMod->setEndPort(cbmod->getInputPort(0)); + conView->updateStartEndPoints(); + + } + + } + + } + + + } + + //========================================================================= } // EO namespace bbtk