X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FEditorGraphicBBS%2FbbsWxGUIEditorGraphic%2FwxVtkSceneManager.cxx;h=3cb95f86f21e22778fb95e3f97f47a42029d7e57;hb=ac275a79f43b892b4b5182f91b980ada0c8f4926;hp=a2cd1dc700c4c9bef41307cd885f9f6e0a409a3f;hpb=61a38c679e47c9f102d2834c835c3c6eac487a9b;p=bbtkGEditor.git diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx index a2cd1dc..3cb95f8 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx @@ -1,4 +1,4 @@ -/*========================================================================= +/*========================================================================= Program: bbtk Module: $RCSfile$ Language: C++ @@ -11,31 +11,35 @@ Version: $Revision$ * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale) * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux * -* This software is governed by the CeCILL-B license under French law and -* abiding by the rules of distribution of free software. You can use, -* modify and/ or redistribute the software under the terms of the CeCILL-B -* license as circulated by CEA, CNRS and INRIA at the following URL -* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +* This software is governed by the CeCILL-B license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL-B +* license as circulated by CEA, CNRS and INRIA at the following URL +* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html * or in the file LICENSE.txt. * * As a counterpart to the access to the source code and rights to copy, * modify and redistribute granted by the license, users are provided only * with a limited warranty and the software's author, the holder of the * economic rights, and the successive licensors have only limited -* liability. +* liability. * * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. -* ------------------------------------------------------------------------ */ +* ------------------------------------------------------------------------ */ /** -* \file -* \brief Class bbtk::wxVtkSceneManager . +* \file +* \brief Class bbtk::wxVtkSceneManager . */ #include "wxVtkSceneManager.h" + #include + #include + + namespace bbtk { @@ -52,14 +56,16 @@ namespace bbtk if( _baseView!=NULL ) { -//EED02JUIN2010 +//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); +#ifdef __APPLE__ + _baseView->GetWxVTKRenderWindowInteractor()->SetDropTarget((wxDropTarget*)parent); +#endif configureBaseView(); _worldState=NOTHING_HAPPENS; registerController(this); - + } _idConnectionInCreation = -1; _contLastId = 0; @@ -82,7 +88,7 @@ namespace bbtk printf ("EED %p ~wxVtkSceneManager()\n" , this ); disconnectDrop(); } - + //========================================================================= void wxVtkSceneManager::configureBaseView() @@ -96,60 +102,87 @@ namespace bbtk interactorstylebaseview->SetInteractor ( iren ); iren->SetInteractorStyle(interactorstylebaseview); interactorstylebaseview->SetwxVtkBaseView(_baseView); - + _baseView->GetRenderer()->GetActiveCamera()->ParallelProjectionOn(); - _baseView->GetRenderer()->ResetCamera(-100,100,-100,100,900,1000); - + _baseView->GetRenderer()->ResetCamera(-100,100,-100,100,800,1100); + _baseView->GetRenderer()->SetBackground(0.9,0.9,0.9); - _baseView->GetRenderer()->GradientBackgroundOff(); + _baseView->GetRenderer()->GradientBackgroundOn(); _baseView->Refresh(); - - // Actos Port_Text + + // Actos Port_Text _textActor = vtkTextActor3D::New(); _textActor->SetPosition( -9999 , -9999 , 900 ); _textActor->SetInput( "" ); - _textActor->GetTextProperty()->SetFontSize(80); + _textActor->GetTextProperty()->SetFontSize(60); _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(); + + vtkPolygon *aPolygon = vtkPolygon::New(); _fillObjectActor = vtkActor::New(); - _fillPolyMapper = vtkPolyDataMapper::New(); - _pts = vtkPoints::New(); - - _pts->SetNumberOfPoints(4); - _pts->SetPoint(0, xInic , yInic , zInic ); - _pts->SetPoint(1, xInic+50 , yInic , zInic ); - _pts->SetPoint(2, xInic+50 , yInic+50 , zInic ); - _pts->SetPoint(3, xInic , yInic+50 , zInic ); - strip->InsertNextCell(5); - strip->InsertCellPoint(0); - strip->InsertCellPoint(1); - strip->InsertCellPoint(2); - strip->InsertCellPoint(0); - strip->InsertCellPoint(3); - pdFill->SetPoints( _pts ); - pdFill->SetStrips( strip ); - _fillPolyMapper->SetInput(pdFill); - _fillObjectActor->SetMapper(_fillPolyMapper); + + _pts = vtkPoints::New(); + + double w=100,h=10,b=h/15,t=3; + _pts->SetNumberOfPoints(21); + _pts->InsertPoint(0, xInic+w*0.33-t/2 , yInic , zInic ); + _pts->InsertPoint(1, xInic+w*0.33 , yInic-t , zInic ); + _pts->InsertPoint(2, xInic+w*0.33+t/2 , yInic , zInic ); + _pts->InsertPoint(3, xInic+w*0.33+t/2 , yInic , zInic ); + _pts->InsertPoint(4, xInic+w-b*4 , yInic+b*0 , zInic ); + + _pts->InsertPoint( 5, xInic+w-b*4 , yInic+b*0 , zInic ); + _pts->InsertPoint( 6, xInic+w-b*2 , yInic+b*1 , zInic ); + _pts->InsertPoint( 7, xInic+w-b*1 , yInic+b*2 , zInic ); + _pts->InsertPoint( 8, xInic+w-b*0 , yInic+b*4 , zInic ); + + _pts->InsertPoint( 9, xInic+w-b*0 , yInic+h-b*4 , zInic ); + _pts->InsertPoint(10, xInic+w-b*1 , yInic+h-b*2 , zInic ); + _pts->InsertPoint(11, xInic+w-b*2 , yInic+h-b*1 , zInic ); + _pts->InsertPoint(12, xInic+w-b*4 , yInic+h-b*0 , zInic ); + + _pts->InsertPoint(13, xInic+b*4 , yInic+h-b*0 , zInic ); + _pts->InsertPoint(14, xInic+b*2 , yInic+h-b*1 , zInic ); + _pts->InsertPoint(15, xInic+b*1 , yInic+h-b*2 , zInic ); + _pts->InsertPoint(16, xInic+b*0 , yInic+h-b*4 , zInic ); + + _pts->InsertPoint(17, xInic+b*0 , yInic+b*4 , zInic ); + _pts->InsertPoint(18, xInic+b*1 , yInic+b*2 , zInic ); + _pts->InsertPoint(19, xInic+b*2 , yInic+b*1 , zInic ); + _pts->InsertPoint(20, xInic+b*4 , yInic+b*0 , zInic ); + + aPolygon->GetPointIds()->SetNumberOfIds(21); + for (int i=0;i<21; i++) + { + aPolygon->GetPointIds()->SetId(i, i); + } + + vtkUnstructuredGrid *aPolygonGrid = vtkUnstructuredGrid::New(); + aPolygonGrid->Allocate(1, 1); + aPolygonGrid->InsertNextCell(aPolygon->GetCellType(), aPolygon->GetPointIds()); + aPolygonGrid->SetPoints(_pts); + _aPolygonMapper = vtkDataSetMapper::New(); + _aPolygonMapper->SetInput(aPolygonGrid); + _fillObjectActor->SetMapper(_aPolygonMapper); _fillObjectActor->GetProperty()->SetColor(PORTFILL_NH_R,PORTFILL_NH_G,PORTFILL_NH_B); - _fillPolyMapper->Modified(); + _fillObjectActor->GetProperty()->SetOpacity(0); + _aPolygonMapper->Modified(); - _baseView->GetRenderer()->AddActor( _fillObjectActor ); + _baseView->GetRenderer()->AddActor( _fillObjectActor ); } //========================================================================= - + std::string wxVtkSceneManager::generateANewNameForABox() { std::stringstream boxname; @@ -164,7 +197,7 @@ namespace bbtk } //========================================================================= - + std::string wxVtkSceneManager::findANewNameForABox() { std::string boxname=generateANewNameForABox(); @@ -185,13 +218,13 @@ namespace bbtk bbmod->setBBTKName(name); bbmod->setInicPoint(xIn,yIn,zIn); bbmod->setFinalPoint(xEn,yEn,zEn); - bbmod->setExecutable(boxExecutable); - + bbmod->setExecutable(boxExecutable); + bbmod->notifyObservers(_idManager); - } - - + } + + //========================================================================= int wxVtkSceneManager::createGBlackBox(int x, int y, std::string packageName, std::string boxType) @@ -203,39 +236,38 @@ namespace bbtk 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); - + 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 + //The coordinates obtained are the following. Top-Left:x=0,y=0 Bottom-Right:x=width,y=height double xx = x; double yy = windowHeight-y; - + //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); - + std::stringstream stream; - + std::string newBoxName; newBoxName = findANewNameForABox(); - - + + stream << newBoxName; - + std::string arraystring = stream.str(); model->setBBTKName(arraystring); model->setBBTKType(boxType); model->setBBTKPackage(packageName); - + model->addObserver(view); model->addObserver(this); @@ -269,13 +301,13 @@ namespace bbtk 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; @@ -288,55 +320,56 @@ namespace bbtk { //EED 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 + + //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; +printf("EED wxVtkSceneManager::createGComplexBoxInputPort 900-450\n"); _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 + + //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) { //EED int windowWidth=_baseView->GetRenWin()->GetSize()[0]; @@ -345,45 +378,47 @@ namespace bbtk 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 + + 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; +printf("EED wxVtkSceneManager::createGComplexBoxOutputPort 900-450\n"); + _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 + + //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; } @@ -418,7 +453,7 @@ namespace bbtk GObjectController* controller = GObjectsMVCFactory::getInstance()->createGObjectController(type); model->registerInBox(blackBox,portType, posInBox); - + model->setBBTKType(bbtkType); model->setBBTKName(bbtkName); @@ -430,7 +465,7 @@ namespace bbtk view->setModel(model); view->setBaseView(_baseView); view->initVtkObjects(); - + //Associates the controller with the correspondent model and view controller->setModelAndView(model,view); @@ -451,7 +486,7 @@ namespace bbtk manualConnectorContourView* manContourView = new manualConnectorContourView(); manualContourModel* manContourModel = new manualContourModel(); - GConnectorController* connectorcontroller = new GConnectorController(); + GConnectorController* connectorcontroller = new GConnectorController(); GConnectorModel* connectorModel = new GConnectorModel(); vtkGConnectorView* connectorView = new vtkGConnectorView(); connectorModel->setGObjectType(type); @@ -471,7 +506,7 @@ namespace bbtk manContourView->SetShowText(false); manContourControl->SetModelView( manContourModel , manContourView ); - + manContourControl->CreateNewManualContour(); manContourView->RefreshContour(); @@ -482,7 +517,7 @@ namespace bbtk manContourControl->SetState(1); manContourModel->SetCloseContour(false); - + manContourModel->AddPoint(x,y,z); manContourView->AddPoint(); @@ -499,12 +534,12 @@ namespace bbtk int newId = addObjectController(connectorcontroller); - connectorcontroller->setManualContourController(manContourControl); + connectorcontroller->setManualContourController(manContourControl); connectorModel->setManualContourModel(manContourModel); connectorView->setManualContourView(manContourView); connectorView->setModel(connectorModel); connectorView->setBaseView(_baseView); - + connectorModel->addObserver(connectorView); connectorModel->addObserver(this); @@ -543,37 +578,65 @@ namespace bbtk } //========================================================================= - + + //========================================================================= + int wxVtkSceneManager::GetIndexInSelected(int idControler) + { + int index=-1; + for (int i=0; i<(int)_selectedObjects.size(); i++) + { + if(_selectedObjects[i]==idControler) + { + index=i; + break; + } + } + return index; + } + //========================================================================= + void wxVtkSceneManager::update(int idController,int command) { + if(command != NO_COMMAND) { if(command == ADD_TO_SELECTED) { -//EED GObjectController* cont = _controllers[idController]; +//EEDBorrame GObjectController* cont = _controllers[idController]; - bool foundID=false; - for (int i=0; i<(int)_selectedObjects.size() && foundID==false; i++) + if (GetIndexInSelected(idController)==-1) { - int id = _selectedObjects[i]; - if(id==idController) - { - foundID = true; - } - } - if(!foundID) - { - int id = idController; - _selectedObjects.push_back(id); + _selectedObjects.push_back(idController); } - } +//EEDBorrame +// bool foundID=false; +// for (int i=0; i<(int)_selectedObjects.size() && foundID==false; i++) +// { +// if(_selectedObjects[i]==idController) +// { +// foundID = true; +// } +// } +// if(!foundID) +// { +// _selectedObjects.push_back(idController); +// } + + }else if(command == REMOVE_FROM_SELECTED) + { + int index=GetIndexInSelected(idController); + if (index>=0) + { + _selectedObjects.erase( _selectedObjects.begin()+index ); + } + } else if(command == INIT_CREATION_CONTOUR) - { - _worldState = INIT_CREATION_CONTOUR; - GObjectController* cont = _controllers[idController]; + { + _worldState = INIT_CREATION_CONTOUR; + GObjectController* cont = _controllers[idController]; GPortModel* startOutputPort = (GPortModel*)cont->getModel(); - + // The last one is the controller of the connector std::map::iterator it2; @@ -600,29 +663,26 @@ namespace bbtk cont->getView()->setState(NOTHING_HAPPENS); cont->getModel()->notifyObservers(_idManager); cont->SetActive(false); - } + } } - _selectedObjects.clear(); - _idConnectionInCreation=createGConnector(startOutputPort); - } else if(command == FIN_CREATION_CONTOUR && _worldState == INIT_CREATION_CONTOUR) - { - _worldState = NOTHING_HAPPENS; + { + _worldState = NOTHING_HAPPENS; //int id = _controllers.size()-1; - GObjectController* cont = _controllers[_idConnectionInCreation]; - GConnectorModel* modelContour = (GConnectorModel*)cont->getModel(); + GObjectController *cont = _controllers[_idConnectionInCreation]; + GConnectorModel *modelContour = (GConnectorModel*)cont->getModel(); + GObjectController *finPort = _controllers[idController]; - GObjectController* finPort = _controllers[idController]; if(finPort->getGObjectType() == GPORT) { GPortModel* modelPort = (GPortModel*)finPort->getModel(); modelContour->setEndPort(modelPort); - } + } - manualConnectorContourController* manCont = ((GConnectorController*)cont)->getManualContourController(); + manualConnectorContourController* manCont = ((GConnectorController*)cont)->getManualContourController(); manualConnectorContourView* connView = (manualConnectorContourView*)manCont->GetManualViewBaseContour(); connView->Refresh(); @@ -636,11 +696,12 @@ namespace bbtk cont->getView()->setState(NOTHING_HAPPENS); cont->getModel()->notifyObservers(_idManager); } - cont->SetActive(true); + cont->SetActive(true); } } - + } + } //========================================================================= @@ -653,10 +714,10 @@ namespace bbtk wxVTKRenderWindowInteractor *wxVTKiren; wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); wxVTKiren->GetEventPosition(X,Y); - - + + if(_worldState == DRAG_OBJECTS) - { + { for (int i=0; i<(int)_selectedObjects.size(); i++) { int id = _selectedObjects[i]; @@ -672,6 +733,7 @@ namespace bbtk std::map::iterator it; + for(it = _controllers.begin(); it != _controllers.end(); ++it) { GObjectController *desc = it->second; @@ -681,7 +743,7 @@ namespace bbtk vconn->updateStartEndPoints(); } } - + _startDragging=false; } @@ -695,7 +757,7 @@ namespace bbtk int type = desc->getGObjectType(); int state = desc->getView()->getState(); desc->getModel()->getCenter(px,py,pz); - + if(state == HIGHLIGHTED){ okStatusMessage = true; updateStatusBar(desc->getStatusText()); @@ -708,42 +770,41 @@ namespace bbtk { // PortText okPortMessage = true; + py=py+5; _textActor->SetInput( desc->getStatusText().c_str() ); _textActor->SetScale(0.1); - _textActor->SetPosition( px-25 ,py , pz+2 ); - + _textActor->SetPosition( px-25 ,py+1 , pz+2 ); + // FillPortText - px=px-35; - _pts->SetPoint(0, px , py , 900+1 ); - _pts->SetPoint(1, px+100, py , 900+1 ); - _pts->SetPoint(2, px+100, py+10 , 900+1 ); - _pts->SetPoint(3, px , py+10 , 900+1 ); - _fillPolyMapper->Modified(); - + px=px-33; + py=py; + _fillObjectActor->SetScale(1); + _fillObjectActor->GetProperty()->SetOpacity(0.50); + _fillObjectActor->SetPosition(px,py,1); + _aPolygonMapper->Modified(); } // if GPORT } // for controllers it - } + } } - - if (okStatusMessage==false) + if (okStatusMessage==false) { updateStatusBar(""); } - - if (okPortMessage==false) + + if (okPortMessage==false) { _textActor->SetScale(0.0001); + _fillObjectActor->SetScale(0.0001); } - - return true; } //========================================================================= - + bool wxVtkSceneManager::OnLeftButtonDown() { + if(_worldState==INIT_CREATION_CONTOUR) { bool isOverPort=false; @@ -753,55 +814,57 @@ namespace bbtk GObjectController *desc = it->second; if(desc->getGObjectType()==GPORT) { - GPortModel* portmod=(GPortModel*)desc->getModel(); - vtkGObjectView* portView=desc->getView(); + GPortModel *portmod = (GPortModel*)desc->getModel(); + vtkGObjectView *portView = desc->getView(); if(portmod->getPortType()==GINPUTPORT && portView->getState()==HIGHLIGHTED) { isOverPort=true; - } - } - } - + } // if + } // if + } // for + if(isOverPort==false) { - _worldState=NOTHING_HAPPENS; - //int lastId = _controllers.size()-1; - GConnectorController *connector = (GConnectorController*)_controllers[_controllers.size()-1]; - connector->removeFromScene(); - unregisterController(connector); - _controllers.erase(_controllers.size()-1); - - for(it = _controllers.begin(); it != _controllers.end(); ++it) + CancelConnection(); + UnSelectBlackBoxes(); + } // isOverPort + + } else { //_worldState + + _worldState = DRAG_OBJECTS; + _startDragging = true; + + int shiftkey = _vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey(); + int ctrlkey = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey(); + ctrlkey = ctrlkey + shiftkey; + + GObjectController *cont = GetGBlackBoxControlerPointedByMouse(); + + + if (GetGBlackBoxControlerPointedByMouse()!=NULL) + { + int state=cont->getView()->getState() ; + if( (ctrlkey==0) && (state==HIGHLIGHTED) ) { - GObjectController *desc = it->second; - desc->SetActive(true); - desc->getView()->setState(NOTHING_HAPPENS); - desc->getModel()->notifyObservers(_idManager); + UnSelectBlackBoxes(); } } - } - - if(_selectedObjects.size()!=0) - { - _worldState = DRAG_OBJECTS; - _startDragging = true; - for (int i = 0; i < (int)_selectedObjects.size(); i++) { int id = _selectedObjects[i]; GObjectController* cont = _controllers[id]; cont->getView()->setState(DRAG); cont->getModel()->notifyObservers(_idManager); - } - } - - + } // for + + } // if _selectedObjects.size + return true; } //========================================================================= - + bool wxVtkSceneManager::OnLeftButtonUp() { if(_worldState == DRAG_OBJECTS) @@ -820,18 +883,18 @@ namespace bbtk } //========================================================================= - - bool wxVtkSceneManager::OnRightButtonUp() + void wxVtkSceneManager::CancelConnection() { if(_worldState==INIT_CREATION_CONTOUR) { _worldState=NOTHING_HAPPENS; //int lastId = _controllers.size()-1; + GConnectorController *connector = (GConnectorController*)_controllers[_idConnectionInCreation]; connector->removeFromScene(); unregisterController(connector); - _controllers.erase(_idConnectionInCreation); - + _controllers.erase(_idConnectionInCreation); + std::map::iterator it; for(it = _controllers.begin(); it != _controllers.end(); ++it) { @@ -839,28 +902,75 @@ namespace bbtk desc->SetActive(true); desc->getView()->setState(NOTHING_HAPPENS); desc->getModel()->notifyObservers(_idManager); - } - } + } // for + }// if + } + + + //========================================================================= - - for (int i = 0; i < (int)_selectedObjects.size(); i++) + bool wxVtkSceneManager::OnRightButtonUp() + { + if(_worldState==INIT_CREATION_CONTOUR) { - int id = _selectedObjects[i]; - GObjectController* cont = _controllers[id]; - cont->SetActive(true); - cont->getView()->setState(NOTHING_HAPPENS); - cont->getModel()->notifyObservers(_idManager); + CancelConnection(); } - - _selectedObjects.clear(); - + UnSelectBlackBoxes(); return true; } //========================================================================= + GObjectController *wxVtkSceneManager::GetGBlackBoxControlerPointedByMouse() + { + GObjectController *result=NULL; + int X,Y; + wxVTKRenderWindowInteractor *wxVTKiren; + wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); + wxVTKiren->GetEventPosition(X,Y); + + std::map::iterator it; + + for(it = _controllers.begin(); it != _controllers.end() ; ++it) + { + GObjectController *cont = it->second; + int type = cont->getGObjectType(); + + if( cont->getView()->isPointInside(X,Y)==true ) + { + if(type==GBLACKBOX) + { + result=cont; + } // if type + } // if isPointInside + } // for it + return result; + } + + //========================================================================= + void wxVtkSceneManager::UnSelectBlackBoxes() + { + for (int i=0; i< (int)_selectedObjects.size(); i++) + { + int id = _selectedObjects[i]; + GObjectController* control = _controllers[id]; + control->getView()->setState(NOTHING_HAPPENS); + }// for _selectedObjects + _selectedObjects.clear(); + } + + //========================================================================= bool wxVtkSceneManager::OnLeftDClick() { + GObjectController *cont = GetGBlackBoxControlerPointedByMouse(); + if (cont!=NULL) + { + UnSelectBlackBoxes(); + _parent->editBlackBox( (GBlackBoxModel*)cont->getModel() ); + } + +/*EED Borrame + int X,Y; wxVTKRenderWindowInteractor *wxVTKiren; wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); @@ -874,7 +984,7 @@ namespace bbtk { GObjectController *cont = it->second; int type = cont->getGObjectType(); - + if(cont->getView()->isPointInside(X,Y)) { if(type==GBLACKBOX) @@ -890,7 +1000,7 @@ namespace bbtk GBlackBoxModel *bbmodel = (GBlackBoxModel*)cont->getModel(); _parent->editBlackBox(bbmodel); } - clickOnObject = true; + clickOnObject = true; } } @@ -898,16 +1008,16 @@ namespace bbtk { //_parent->editDiagramParameters(this); } - +*/ return true; } - + //========================================================================= bool wxVtkSceneManager::OnChar() - { + { char keyCode = _vtkInteractorStyleBaseView->GetInteractor()-> GetKeyCode(); - + // KeyCode 127 : Delete Key // KeyCode 8 : Backspace Key if(keyCode == 8 || keyCode == 127) @@ -916,7 +1026,7 @@ namespace bbtk { for(int i=0;i<(int)_selectedObjects.size();i++) { - int id = _selectedObjects[i]; + int id = _selectedObjects[i]; std::map::iterator it; it = _controllers.find(id); if (it!=_controllers.end()) @@ -935,7 +1045,7 @@ namespace bbtk void wxVtkSceneManager::AddControlerToBeRemove(std::vector *controllersToRemove, int id) { - + int i; bool ok=true; for(i=0 ; i < (int)controllersToRemove->size() ; i++ ) @@ -945,16 +1055,16 @@ namespace bbtk ok=false; } } - + if (ok==true) { controllersToRemove->push_back( id ); } - + } - + //========================================================================= - + void wxVtkSceneManager::deleteObject(int id) { GObjectController *control = _controllers[id]; @@ -964,7 +1074,7 @@ namespace bbtk { GBoxModel *bbmod = (GBoxModel*)control->getModel(); std::vector inputs = bbmod->getInputPorts(); - + bool boxConnected = false; // Add box input controllers to be removed @@ -1013,12 +1123,12 @@ namespace bbtk AddControlerToBeRemove( &controllersToRemove, bbmod->getObjectId() ); } else if(control->getGObjectType()==GCONNECTOR) - { + { GConnectorModel *conMod = (GConnectorModel*)control->getModel(); AddControlerToBeRemove( &controllersToRemove, conMod->getObjectId() ); } - + std::map::iterator it; for(int i = 0;i<(int)controllersToRemove.size();i++) @@ -1029,7 +1139,7 @@ namespace bbtk if(cont!=NULL) { cont->removeFromScene(); - unregisterController((InteractorStyleMaracas*)cont); + unregisterController((InteractorStyleMaracas*)cont); _controllers.erase(it); }//if }// for @@ -1049,9 +1159,32 @@ namespace bbtk _parent->updateStatusBar(textStatus); } + + //========================================================================= + std::string wxVtkSceneManager::LineNumber(bool withLineNumber, int &value) + { + std::string result=""; + if (withLineNumber==true) + { + value++; + stringstream StrStream; + StrStream << value; + std::string strValue=StrStream.str(); + if (value<10) + { + result+=" "; + }else if (value<100) + { + result+=" "; + } + + result+=strValue+": "; + } + return result; + } //========================================================================= - std::string wxVtkSceneManager::getDiagramBBS() + std::string wxVtkSceneManager::getDiagramBBS(bool wln) { bool existsExec=false; @@ -1070,7 +1203,7 @@ namespace bbtk if(type==GBLACKBOX) { GBlackBoxModel *mod = (GBlackBoxModel*)desc->getModel(); - + std::string pkg = mod->getBBTKPackage(); bool existsPkg = false; for(int t = 0;t< (int)packages.size() && existsPkg == false;t++) @@ -1099,27 +1232,32 @@ namespace bbtk } } + int lnNmbr=0; std::string script = ""; - script+="# BBTK GEditor Script\n"; - script+="# ----------------------\n"; - script+="\n"; + script+=LineNumber(wln,lnNmbr)+"# BBTK GEditor Script\n"; + script+=LineNumber(wln,lnNmbr)+"# ----------------------\n"; + script+=LineNumber(wln,lnNmbr)+"\n"; if(existsExec) { - script+="include std\n"; // EED - script+="include itkvtk\n"; // EED + script+=LineNumber(wln,lnNmbr)+"include std\n"; // EED + script+=LineNumber(wln,lnNmbr)+"include itkvtk\n"; // EED int i; for(i = 0; i< (int)packages.size();i++) { + script+=LineNumber(wln,lnNmbr); script+="include "; script+=packages[i]; script+="\n"; } + + script+=LineNumber(wln,lnNmbr); script+="\n"; // script+="include std\n"; // JPR for(i = 0; i < (int)boxes.size();i++) { + script+=LineNumber(wln,lnNmbr); script+="new "; int id = boxes[i]; GObjectController *control = _controllers[id]; @@ -1136,6 +1274,7 @@ namespace bbtk GPortModel* inputPort = inputs[j]; if(inputPort->isValueSet()) { + script+=LineNumber(wln,lnNmbr); script+=" set "; script+=model->getBBTKName(); script+="."; @@ -1145,14 +1284,18 @@ namespace bbtk script+="\n"; } } + + script+=LineNumber(wln,lnNmbr); script+="\n"; } + script+=LineNumber(wln,lnNmbr); script+="\n"; for(i = 0; i<(int)connections.size();i++) { + script+=LineNumber(wln,lnNmbr); script+="connect "; int id = connections[i]; GObjectController *control = _controllers[id]; @@ -1175,9 +1318,11 @@ namespace bbtk script+="\n"; } + script+=LineNumber(wln,lnNmbr); script+="\n"; for(i = 0; i<(int)execBoxes.size();i++) { + script+=LineNumber(wln,lnNmbr); script+="exec "; int id = execBoxes[i]; GObjectController *control = _controllers[id]; @@ -1212,7 +1357,7 @@ namespace bbtk if(type==GBLACKBOX) { GBlackBoxModel *mod = (GBlackBoxModel*)desc->getModel(); - + std::string pkg = mod->getBBTKPackage(); bool existsPkg = false; for(int t = 0;t<(int)packages.size() && existsPkg == false;t++) @@ -1368,7 +1513,7 @@ namespace bbtk } script+="\n"; - + for(i = 0; i<(int)execBoxes.size();i++) { script+="exec "; @@ -1390,7 +1535,7 @@ namespace bbtk script+="\n"; script+="endefine"; - script+="\n"; + script+="\n"; return script; } @@ -1398,28 +1543,35 @@ namespace bbtk //========================================================================= void wxVtkSceneManager::deleteAllBoxes() - { + { std::map::iterator it; for(it = _controllers.begin(); it != _controllers.end(); ++it) { - GObjectController *cont = it->second; + GObjectController *cont = it->second; cont->removeFromScene(); unregisterController((InteractorStyleMaracas*)cont); } _selectedObjects.clear(); - _controllers.clear(); + _controllers.clear(); refreshScene(); } //========================================================================= + + void wxVtkSceneManager::refresh() + { + _baseView->Refresh(); + } + //========================================================================= + void wxVtkSceneManager::refreshScene() { _baseView->RefreshView(); } //========================================================================= - + void wxVtkSceneManager::centerView() { double temp[3]; @@ -1450,7 +1602,7 @@ namespace bbtk sprintf (buffer, "%d", insize); content+=buffer; content+="\n"; - + for(int i = 0;i> numInputs; - + for(int i = 0;igetModel(); -// cbmod->setInicPoint(xIn,yIn,zIn); -// cbmod->notifyObservers(_idManager); - } // for input complex box @@ -1612,11 +1764,11 @@ namespace bbtk 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;igetModel(); -// cbmod->setInicPoint(xIn,yIn,zIn); -// cbmod->notifyObservers(_idManager); - + } // for output complex box } // complex box @@ -1664,11 +1809,11 @@ namespace bbtk 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> yIn; std::istringstream zSt(zInic); zSt >> zIn; - + //---------- getline(inputStream,line);//xEnd:yEnd:zEnd strcpy( coord, line.c_str() ); @@ -1732,23 +1877,14 @@ namespace bbtk { 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 std::string port=line.substr(0,4); @@ -1762,11 +1898,11 @@ namespace bbtk result = strtok( NULL, delims );//value std::string value(result); - bbmod->setValueToInput(name,value); + bbmod->setValueToInput(name,value); getline(inputStream,line);//PORT o FIN_BOX port=line.substr(0,4); - } // while + } // while //EED bbmod->notifyObservers(_idManager); } // for boxes @@ -1778,11 +1914,11 @@ namespace bbtk 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 lstB = getBlackBoxes(); - GPortModel *startP = NULL; - GPortModel *endP = NULL; - int j; - for(j = 0;jgetModel(); - if(_controllers[idB]->getModel()->getBBTKName()==nameStartBox) - { - startP = bbMod->getOutputPort(nameStartPort); - } - else if(_controllers[idB]->getModel()->getBBTKName()==nameEndBox) + //Readding control points of the manualContour + //ups1 + GConnectorController *tempp = (GConnectorController*)_controllers[idCon]; + GConnectorModel *conMod = (GConnectorModel*)tempp->getModel(); + vtkGConnectorView *conView= (vtkGConnectorView*)tempp->getView(); + getline(inputStream,line); //NumberOfControlPoints:## + strcpy( conns, line.c_str() ); + result = strtok( conns, delims ); + result = strtok( NULL, delims ); + + int numberOfControlPoints; + std::istringstream isCons(result); + isCons >> numberOfControlPoints; + + for (int ii=0;iigetInputPort(nameEndPort); + getline(inputStream,line); //XX:YY:ZZ + char connec[200]; + strcpy( connec, line.c_str() ); + + double px,py,pz; + result = strtok( connec, delims ); + std::istringstream isPointX(result); + isPointX >> px; + result = strtok( NULL, delims ); + std::istringstream isPointY(result); + isPointY >> py; + result = strtok( NULL, delims ); + std::istringstream isPointZ(result); + isPointZ >> pz; + + conMod->getManualContourModel()->InsertPoint_id(ii+1,px,py,pz); + conView->getManualContourView()->AddPoint(); } - } // for - - if(_isComplexBox) - { - if(startP==NULL) - { - std::vector lstInputs = getComplexInputPorts(); - for(j = 0;jgetModel(); - if(_controllers[idB]->getModel()->getBBTKName()==nameStartBox) - { - startP = cbMod->getOutputPort(nameStartPort); - } // if - } // for - } // if - - if(endP==NULL) - { - std::vector lstOutputs = getComplexOutputPorts(); - for(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; - GConnectorController *tempp = (GConnectorController*)_controllers[idCon]; - - GConnectorModel *conMod = (GConnectorModel*)tempp->getModel(); - vtkGConnectorView *conView = (vtkGConnectorView*)tempp->getView(); - tempp->endContourCreation(); - conMod->setEndPort(endP); - conView->updateStartEndPoints(); - */ + }// version !=1.0 + } // for numConns - - } // start + } // start + + refresh(); } //========================================================================= - - - //========================================================================= + + + //========================================================================= void wxVtkSceneManager::configGComBoxInputOutputPort(bool inputoutput, std::string portName, double xIn, double yIn,double zIn) { int idPort; @@ -1884,19 +1999,19 @@ namespace bbtk GObjectController *cont = _controllers[idPort]; GBoxModel *cbmod = (GBoxModel*)cont->getModel(); cbmod->setInicPoint(xIn,yIn,zIn); - cbmod->notifyObservers(_idManager); + cbmod->notifyObservers(_idManager); } //========================================================================= - - + + //========================================================================= GBoxModel* wxVtkSceneManager::findGBox(std::string boxname) - { + { int j; int idB; GBoxModel *bMod; GBoxModel *boxModel = NULL; - std::vector lstB = getBlackBoxes(); + std::vector lstB = getBlackBoxes(); for(j = 0;j<(int)lstB.size();j++) { idB = lstB[j]; @@ -1906,7 +2021,7 @@ namespace bbtk boxModel = bMod; } } // for - + if((_isComplexBox) && (boxModel==NULL)) { std::vector lstInputs = getComplexInputPorts(); @@ -1917,37 +2032,36 @@ namespace bbtk 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 + int 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) { @@ -1960,67 +2074,17 @@ namespace bbtk 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 - */ - +//ups2 int idCon = createGConnector(startP); _worldState = NOTHING_HAPPENS; - GConnectorController *tempp = (GConnectorController*)_controllers[idCon]; - + GConnectorController *tempp = (GConnectorController*)_controllers[idCon]; + GConnectorModel *conMod = (GConnectorModel*)tempp->getModel(); vtkGConnectorView *conView = (vtkGConnectorView*)tempp->getView(); tempp->endContourCreation(); - conMod->setEndPort(endP); - conView->updateStartEndPoints(); + conMod->setEndPort(endP); + conView->updateStartEndPoints(); + return idCon; } //========================================================================= @@ -2031,7 +2095,7 @@ namespace bbtk std::map::iterator it; for(it = _controllers.begin(); it != _controllers.end(); ++it) { - GObjectController *cont = it->second; + GObjectController *cont = it->second; if(cont->getModel()->getBBTKName()==boxname) { ok=true; @@ -2048,7 +2112,7 @@ namespace bbtk std::map::iterator it; for(it = _controllers.begin(); it != _controllers.end(); ++it) { - GObjectController *cont = it->second; + GObjectController *cont = it->second; if(cont->getGObjectType()==GBLACKBOX) { vect.push_back(cont->getId()); @@ -2065,7 +2129,7 @@ namespace bbtk std::map::iterator it; for(it = _controllers.begin(); it != _controllers.end(); ++it) { - GObjectController *cont = it->second; + GObjectController *cont = it->second; if(cont->getGObjectType()==GCOMPLEXINPUTPORT) { vect.push_back(cont->getId()); @@ -2082,7 +2146,7 @@ namespace bbtk std::map::iterator it; for(it = _controllers.begin(); it != _controllers.end(); ++it) { - GObjectController *cont = it->second; + GObjectController *cont = it->second; if(cont->getGObjectType()==GCOMPLEXOUTPUTPORT) { vect.push_back(cont->getId()); @@ -2099,7 +2163,7 @@ namespace bbtk std::map::iterator it; for(it = _controllers.begin(); it != _controllers.end(); ++it) { - GObjectController *cont = it->second; + GObjectController *cont = it->second; if(cont->getGObjectType()==GCONNECTOR) { vect.push_back(cont->getId()); @@ -2109,7 +2173,7 @@ namespace bbtk } //========================================================================= - + bool wxVtkSceneManager::isComplexBox() { return _isComplexBox; @@ -2121,7 +2185,7 @@ namespace bbtk { _isComplexBox=val; } - + //========================================================================= int wxVtkSceneManager::addObjectController(GObjectController* objController) @@ -2129,7 +2193,7 @@ namespace bbtk //Register the controller of the new object registerController((InteractorStyleMaracas*) objController); - //Add the object to the objects list + //Add the object to the objects list int newId = _contLastId;//_controllers.size(); objController->setId(newId); _controllers[newId] = objController; @@ -2153,7 +2217,7 @@ namespace bbtk std::map::iterator it; for(it = _controllers.begin(); it != _controllers.end(); ++it) { - GObjectController *cont = it->second; + GObjectController *cont = it->second; if(cont->getGObjectType()==GBLACKBOX && cont->getView()->getState()==SELECTED) { mapSelected[cont->getId()]=cont; @@ -2163,7 +2227,7 @@ namespace bbtk std::map::iterator it2; for(it2 = _controllers.begin(); it2 != _controllers.end(); ++it2) { - GObjectController *cont = it2->second; + GObjectController *cont = it2->second; if(cont->getGObjectType()==GCONNECTOR) { GConnectorModel* cmod = (GConnectorModel*)cont->getModel(); @@ -2172,12 +2236,12 @@ namespace bbtk 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; @@ -2187,11 +2251,11 @@ namespace bbtk void wxVtkSceneManager::addObjects(std::map objectsMap) { - + std::map oldIdNewIdBoxes; std::vector connections; - std::map::iterator it; + std::map::iterator it; for(it = objectsMap.begin(); it != objectsMap.end(); ++it) { GObjectController *cont = it->second; @@ -2207,9 +2271,9 @@ namespace bbtk int idcB = copyBox->getObjectId(); oldIdNewIdBoxes[idcB]=idBox; - cont = _controllers[idBox]; + cont = _controllers[idBox]; GBlackBoxModel* newbox = (GBlackBoxModel*)cont->getModel(); - newbox->setInicPoint(xInic,yInic,zInic); + newbox->setInicPoint(xInic,yInic,zInic); int num = newbox->getNumInputPorts(); for(int j=0;jgetId(); connections.push_back(idCon); } - + } - + for(int i = 0 ;i<(int)connections.size();i++) { int objId = connections[i]; - GObjectController *cont = objectsMap[objId]; + GObjectController *cont = objectsMap[objId]; GConnectorModel* connectModel = (GConnectorModel*)cont->getModel(); - + GPortModel* startPort = connectModel->getStartPort(); int startPortIndex = startPort->getPosInBox(); GPortModel* endPort = connectModel->getEndPort(); - int endPortIndex = endPort->getPosInBox(); + int endPortIndex = endPort->getPosInBox(); GBlackBoxModel* startPortParentBox = (GBlackBoxModel*)startPort->getParentBox(); GBlackBoxModel* endPortParentBox = (GBlackBoxModel*)endPort->getParentBox(); - + int idNewStartBox = oldIdNewIdBoxes[startPortParentBox->getObjectId()]; int idNewEndBox = oldIdNewIdBoxes[endPortParentBox->getObjectId()]; @@ -2248,17 +2312,17 @@ namespace bbtk GPortModel* newStartPort = newStartBox->getOutputPort(startPortIndex); GPortModel* newEndPort = newEndBox->getInputPort(endPortIndex); - // Creates connection + // Creates connection int idCon = createGConnector(newStartPort); - GConnectorController *tempp = (GConnectorController*)_controllers[idCon]; + GConnectorController *tempp = (GConnectorController*)_controllers[idCon]; GConnectorModel *conMod = (GConnectorModel*)tempp->getModel(); vtkGConnectorView *conView = (vtkGConnectorView*)tempp->getView(); tempp->endContourCreation(); - conMod->setEndPort(newEndPort); + conMod->setEndPort(newEndPort); conView->updateStartEndPoints(); } - std::map::iterator itIds; + std::map::iterator itIds; for(itIds = oldIdNewIdBoxes.begin(); itIds != oldIdNewIdBoxes.end(); ++itIds) { int idOld = itIds->first; @@ -2286,7 +2350,7 @@ namespace bbtk if(exist==false) { - //Create complex input + //Create complex input int posInBox = oldInputConnections[k]; GPortModel* inputPort = oldBox->getInputPort(posInBox); std::string inputPortName = inputPort->getBBTKName(); @@ -2298,22 +2362,22 @@ namespace bbtk yIn+=20; cbmod->setInicPoint(xIn,yIn,zIn); cbmod->notifyObservers(_idManager); - + GPortModel* inputPortEnd = newBox->getInputPort(posInBox); - // Creates connection + // Creates connection int idCon = createGConnector(cbmod->getOutputPort(0)); - GConnectorController *tempp = (GConnectorController*)_controllers[idCon]; + GConnectorController *tempp = (GConnectorController*)_controllers[idCon]; GConnectorModel *conMod = (GConnectorModel*)tempp->getModel(); vtkGConnectorView *conView = (vtkGConnectorView*)tempp->getView(); tempp->endContourCreation(); - conMod->setEndPort(inputPortEnd); + conMod->setEndPort(inputPortEnd); conView->updateStartEndPoints(); } - + } - + for(int k = 0; k<(int)oldOutputConnections.size();k++) { @@ -2329,7 +2393,7 @@ namespace bbtk if(exist==false) { - //Create complex output + //Create complex output int posInBox = oldOutputConnections[k]; GPortModel* outputPort = oldBox->getOutputPort(posInBox); std::string outputPortName = outputPort->getBBTKName(); @@ -2341,20 +2405,20 @@ namespace bbtk yIn-=20; cbmod->setInicPoint(xIn,yIn,zIn); cbmod->notifyObservers(_idManager); - + GPortModel* outputPortEnd = newBox->getOutputPort(posInBox); - // Creates connection + // Creates connection int idCon = createGConnector(outputPortEnd); - GConnectorController *tempp = (GConnectorController*)_controllers[idCon]; + GConnectorController *tempp = (GConnectorController*)_controllers[idCon]; GConnectorModel *conMod = (GConnectorModel*)tempp->getModel(); vtkGConnectorView *conView = (vtkGConnectorView*)tempp->getView(); tempp->endContourCreation(); - conMod->setEndPort(cbmod->getInputPort(0)); + conMod->setEndPort(cbmod->getInputPort(0)); conView->updateStartEndPoints(); } - + } } @@ -2362,7 +2426,7 @@ namespace bbtk } - //========================================================================= + //========================================================================= } // EO namespace bbtk