X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FEditorGraphicBBS%2FbbsWxGUIEditorGraphic%2FwxVtkSceneManager.cxx;h=5c8e2106dc569c61634e2ebbb6c1e4765d43ccc4;hb=e9ab2c3abb5398388f62fcb9414df85be0eb37d8;hp=4a30692602d990b6e8dd43403d6fada88180fb60;hpb=6a326b219e8d69c186f8cff4e82c64b622fc9288;p=bbtkGEditor.git diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx index 4a30692..5c8e210 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx @@ -36,6 +36,10 @@ Version: $Revision$ #include "wxVtkSceneManager.h" + #include + #include + + namespace bbtk { @@ -43,12 +47,12 @@ namespace bbtk //========================================================================= wxVtkSceneManager::wxVtkSceneManager(wxGEditorTabPanel *parent, wxVtk3DBaseView *baseView,int idManager) { - _parent = parent; - _numBoxes=0; - _idManager=idManager; - _baseView=baseView; - _startDragging=false; - _isComplexBox=false; + _parent = parent; + _numBoxes = 0; + _idManager = idManager; + _baseView = baseView; + _startDragging = false; + _isComplexBox = false; if( _baseView!=NULL ) { @@ -61,8 +65,8 @@ namespace bbtk registerController(this); } - _idConnectionInCreation=-1; - _contLastId=0; + _idConnectionInCreation = -1; + _contLastId = 0; } @@ -103,25 +107,148 @@ namespace bbtk _baseView->GetRenderer()->SetBackground(0.9,0.9,0.9); _baseView->GetRenderer()->GradientBackgroundOff(); _baseView->Refresh(); + + // Actos Port_Text + _textActor = vtkTextActor3D::New(); + _textActor->SetPosition( -9999 , -9999 , 900 ); + _textActor->SetInput( "" ); + _textActor->GetTextProperty()->SetFontSize(40); + _textActor->GetTextProperty()->BoldOn(); + _textActor->GetTextProperty()->SetColor(PORTTEXT_NH_R,PORTTEXT_NH_G,PORTTEXT_NH_B); + + _baseView->GetRenderer()->AddActor( _textActor ); + + + // Actor Fill_Port_Text + + //------------ + double xInic = 0; + double yInic = 0; + double zInic = 900; +/* + vtkCellArray *strip = vtkCellArray::New(); + vtkPolyData *pdFill = vtkPolyData::New(); + _fillObjectActor = vtkActor::New(); + _fillPolyMapper = vtkPolyDataMapper::New(); +*/ +printf ("EED wxVtkSceneManager::configureBaseView 1...\n"); + + vtkPolygon *aPolygon = vtkPolygon::New(); + _fillObjectActor = vtkActor::New(); + + _pts = vtkPoints::New(); +//ups4 EED Borrame + _pts->SetNumberOfPoints(7); + _pts->InsertPoint(0, xInic , yInic , zInic ); + _pts->InsertPoint(1, xInic+50 , yInic , zInic ); + _pts->InsertPoint(2, xInic+50 , yInic+50 , zInic ); + _pts->InsertPoint(3, xInic+25 , yInic+50 , zInic ); + _pts->InsertPoint(4, xInic+20 , yInic+55 , zInic ); + _pts->InsertPoint(5, xInic+15 , yInic+50 , zInic ); + _pts->InsertPoint(6, xInic , yInic+50 , zInic ); + +/* + strip->InsertNextCell(8); + strip->InsertCellPoint(0); + strip->InsertCellPoint(1); + strip->InsertCellPoint(2); + strip->InsertCellPoint(0); + strip->InsertCellPoint(3); + pdFill->SetPoints( _pts ); + pdFill->SetStrips( strip ); + _fillPolyMapper->SetInput(pdFill); +*/ + +printf ("EED wxVtkSceneManager::configureBaseView 2...\n"); + + aPolygon->GetPointIds()->SetNumberOfIds(7); + aPolygon->GetPointIds()->SetId(0, 0); + aPolygon->GetPointIds()->SetId(1, 1); + aPolygon->GetPointIds()->SetId(2, 2); + aPolygon->GetPointIds()->SetId(3, 3); + aPolygon->GetPointIds()->SetId(4, 4); + aPolygon->GetPointIds()->SetId(5, 5); + aPolygon->GetPointIds()->SetId(6, 6); + +printf ("EED wxVtkSceneManager::configureBaseView 3...\n"); + + vtkUnstructuredGrid *aPolygonGrid = vtkUnstructuredGrid::New(); + aPolygonGrid->Allocate(1, 1); + aPolygonGrid->InsertNextCell(aPolygon->GetCellType(), aPolygon->GetPointIds()); + aPolygonGrid->SetPoints(_pts); +printf ("EED wxVtkSceneManager::configureBaseView 4...\n"); + _aPolygonMapper = vtkDataSetMapper::New(); + _aPolygonMapper->SetInput(aPolygonGrid); + _fillObjectActor->SetMapper(_aPolygonMapper); +printf ("EED wxVtkSceneManager::configureBaseView 5...\n"); + _fillObjectActor->GetProperty()->SetColor(PORTFILL_NH_R,PORTFILL_NH_G,PORTFILL_NH_B); + _aPolygonMapper->Modified(); + + _baseView->GetRenderer()->AddActor( _fillObjectActor ); +printf ("EED wxVtkSceneManager::configureBaseView fin...\n"); } //========================================================================= + + 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() { - _worldState = NOTHING_HAPPENS; - 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; + } + + //========================================================================= + 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 @@ -135,17 +262,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); @@ -202,24 +326,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); @@ -255,24 +379,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); @@ -329,9 +453,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); @@ -352,7 +476,7 @@ namespace bbtk model->notifyObservers(_idManager); - int newId = addObjectController(controller); + addObjectController(controller); return (GPortController*)controller; } @@ -364,12 +488,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); @@ -466,10 +590,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) @@ -564,6 +688,8 @@ namespace bbtk bool wxVtkSceneManager::OnMouseMove() { int X,Y; + bool okStatusMessage = false; + bool okPortMessage = false; wxVTKRenderWindowInteractor *wxVTKiren; wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); wxVTKiren->GetEventPosition(X,Y); @@ -571,7 +697,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]; @@ -602,25 +728,64 @@ namespace bbtk else if(_worldState == NOTHING_HAPPENS || _worldState == INIT_CREATION_CONTOUR) { std::map::iterator it; - + double px, py, pz; for(it = _controllers.begin(); it != _controllers.end(); ++it) { GObjectController *desc = it->second; - int type = desc->getGObjectType(); - int state = desc->getView()->getState(); + int type = desc->getGObjectType(); + int state = desc->getView()->getState(); + desc->getModel()->getCenter(px,py,pz); if(state == HIGHLIGHTED){ - + okStatusMessage = true; updateStatusBar(desc->getStatusText()); if(type==GBLACKBOX) { GBlackBoxModel *mod = (GBlackBoxModel*)desc->getModel(); _parent->displayBlackBoxInfo(mod->getBBTKPackage(),mod->getBBTKType()); - } - } - } + } // if GBLACKBOX + if(type==GPORT) + { + // PortText + okPortMessage = true; + py=py+5; + _textActor->SetInput( desc->getStatusText().c_str() ); + _textActor->SetScale(0.1); + _textActor->SetPosition( px-25 ,py , pz+2 ); + + // FillPortText + px=px-35; + py=py-2; +/* + _pts->SetPoint(0, px , py , 900+1 ); + _pts->SetPoint(1, px+150 , py , 900+1 ); + _pts->SetPoint(2, px+150 , py+7 , 900+1 ); + _pts->SetPoint(3, px-150+40 , py+7 , 900+1 ); + _pts->SetPoint(4, px-150+40-5 , py+7+5 , 900+1 ); + _pts->SetPoint(5, px-150+40-10 , py+7 , 900+1 ); + _pts->SetPoint(6, px , py+7 , 900+1 ); +*/ + _fillObjectActor->SetScale(1); + _fillObjectActor->SetPosition(px,py,1); + _aPolygonMapper->Modified(); + } // if GPORT + + } // for controllers it + } + } +//ups4 EED Borrame + if (okStatusMessage==false) + { + updateStatusBar(""); + } + + if (okPortMessage==false) + { + _textActor->SetScale(0.0001); + _fillObjectActor->SetScale(0.0001); } + return true; } @@ -670,7 +835,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]; @@ -692,7 +857,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]; @@ -727,7 +892,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]; @@ -763,7 +928,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]; @@ -957,7 +1122,7 @@ namespace bbtk std::string pkg = mod->getBBTKPackage(); 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(); @@ -1027,10 +1194,13 @@ namespace bbtk script+="\n"; } } + script+="\n"; } - 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(); @@ -1171,6 +1345,7 @@ namespace bbtk script+="\n"; } } + script+="\n"; } @@ -1178,8 +1353,9 @@ namespace bbtk std::string complexInputs=""; std::string complexOutputs=""; + script+="\n"; - for(i = 0; igetModel(); - cbmod->setInicPoint(xIn,yIn,zIn); - cbmod->notifyObservers(_idManager); + configGComBoxInputOutputPort(true, inputPortName,xIn,yIn,zIn); + +//ups3 EED Borrame +// int idInputPort = createGComplexBoxInputPort(inputPortName); +// GObjectController *cont = _controllers[idInputPort]; +// GBoxModel *cbmod = (GBoxModel*)cont->getModel(); +// cbmod->setInicPoint(xIn,yIn,zIn); +// cbmod->notifyObservers(_idManager); + + } // for input complex box @@ -1511,11 +1694,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); + configGComBoxInputOutputPort(false, outputPortName,xIn,yIn,zIn); + +//ups 3 EED Borrame +// 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 @@ -1589,20 +1776,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 @@ -1623,8 +1817,8 @@ namespace bbtk port=line.substr(0,4); } // while - bbmod->notifyObservers(_idManager); - } // boxes +//EED bbmod->notifyObservers(_idManager); + } // for boxes /// CONNECTIONS //---------- @@ -1655,11 +1849,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(); @@ -1678,30 +1875,30 @@ namespace bbtk 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); @@ -1713,11 +1910,184 @@ namespace bbtk tempp->endContourCreation(); conMod->setEndPort(endP); conView->updateStartEndPoints(); - + */ } // for numConns + } // start } + //========================================================================= + + + + //========================================================================= + void wxVtkSceneManager::configGComBoxInputOutputPort(bool inputoutput, std::string portName, double xIn, double yIn,double zIn) + { + int idPort; + if (inputoutput==true) + { + idPort = createGComplexBoxInputPort(portName); + } else { + idPort = createGComplexBoxOutputPort(portName); + } + GObjectController *cont = _controllers[idPort]; + GBoxModel *cbmod = (GBoxModel*)cont->getModel(); + cbmod->setInicPoint(xIn,yIn,zIn); + cbmod->notifyObservers(_idManager); + } + //========================================================================= + + + //========================================================================= + GBoxModel* wxVtkSceneManager::findGBox(std::string boxname) + { + int j; + int idB; + GBoxModel *bMod; + GBoxModel *boxModel = NULL; + std::vector lstB = getBlackBoxes(); + for(j = 0;j<(int)lstB.size();j++) + { + idB = lstB[j]; + bMod = (GBoxModel*)_controllers[idB]->getModel(); + if(_controllers[idB]->getModel()->getBBTKName()==boxname) + { + boxModel = bMod; + } + } // for + + if((_isComplexBox) && (boxModel==NULL)) + { + std::vector lstInputs = getComplexInputPorts(); + for(j = 0;j<(int)lstInputs.size();j++) + { + idB = lstInputs[j]; + bMod = (GBoxModel*)_controllers[idB]->getModel(); + if(_controllers[idB]->getModel()->getBBTKName()==boxname) + { + boxModel = bMod; + } + } // for + + std::vector lstOutputs = getComplexOutputPorts(); + for(j = 0;j<(int)lstOutputs.size();j++) + { + int idB = lstOutputs[j]; + bMod = (GBoxModel*)_controllers[idB]->getModel(); + if(_controllers[idB]->getModel()->getBBTKName()==boxname) + { + boxModel = bMod; + } + } // for + + } // complex box + + return boxModel; + } + + //========================================================================= + + + void wxVtkSceneManager::configGConnetion(std::string nameStartBox, std::string nameStartPort, std::string + nameEndBox, std::string nameEndPort) + { + printf("EED wxVtkSceneManager::configGConnetion 1 %s %s %s %s\n", nameStartBox.c_str(), nameStartPort.c_str(), nameEndBox.c_str(), nameEndPort.c_str() ); + + GBoxModel *boxModel; + GPortModel *startP = NULL; + GPortModel *endP = NULL; + + boxModel= findGBox(nameStartBox); + if (boxModel!=NULL) + { + startP = boxModel->getOutputPort(nameStartPort); + } + + boxModel= findGBox(nameEndBox); + if (boxModel!=NULL) + { + endP = boxModel->getInputPort(nameEndPort); + } + + + printf("EED wxVtkSceneManager::configGConnetion 2 %p %p \n", startP, endP ); + +/*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 + + 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; + } //========================================================================= @@ -1856,8 +2226,7 @@ namespace bbtk { int ID = cont->getId(); mapSelected[ID]=cont; - } - + } } } return mapSelected; @@ -1905,7 +2274,7 @@ namespace bbtk } - for(int i = 0 ;i newInputConnections = newBox->getConnectedInputs(); std::vector newOutputConnections = newBox->getConnectedOutputs(); - for(int k = 0; k