]> Creatis software - bbtkGEditor.git/blobdiff - lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx
no message
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsWxGUIEditorGraphic / wxVtkSceneManager.cxx
index dae6833dea58c02ae75a5e1959ac2fef70f076f2..66c468a242fab2830160dfe9299a1c5ce43368b1 100644 (file)
@@ -36,6 +36,10 @@ Version:   $Revision$
 
 #include "wxVtkSceneManager.h"
 
+ #include <vtkPolygon.h>
+ #include <vtkUnstructuredGrid.h>
+
+
 namespace bbtk
 {
 
@@ -43,24 +47,26 @@ 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;
+               _parent                 = parent;
+               _numBoxes               = 0;
+               _idManager              = idManager;
+               _baseView               = baseView;
+               _startDragging  = false;
+               _isComplexBox   = false;
 
                if( _baseView!=NULL )
                {
 //EED02JUIN2010        
                        printf ("RaC-EED 21-06-2010 %p wxVtkSceneManager::wxVtkSceneManager If you comment this line, the drag and drop functionnality is not initialized.\n" , this );
                        _baseView->GetWxVTKRenderWindowInteractor()->SetDropTarget((wxDropTarget*)parent);                      
+
                        configureBaseView();
                        _worldState=NOTHING_HAPPENS;
                        registerController(this);
                        
                }
+               _idConnectionInCreation = -1;
+               _contLastId                             = 0;
 
        }
 
@@ -96,29 +102,145 @@ namespace bbtk
                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 
+               _textActor = vtkTextActor3D::New();
+               _textActor->SetPosition(  -9999 , -9999 , 900 );
+               _textActor->SetInput( "<void>" );
+               _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;
+
+               vtkPolygon *aPolygon = vtkPolygon::New();
+               _fillObjectActor                                                = vtkActor::New();
+
+                                                       _pts                            = vtkPoints::New();     
+//ups4 EED Borrame
+               
+               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);
+               _fillObjectActor->GetProperty()->SetOpacity(0);
+               _aPolygonMapper->Modified();
+
+               _baseView->GetRenderer()->AddActor( _fillObjectActor );         
        }
 
        //=========================================================================
+  
+       std::string wxVtkSceneManager::generateANewNameForABox()
+       {
+               std::stringstream boxname;
+               if(_numBoxes<10)
+               {
+                       boxname << "Box0" << _numBoxes;
+               }else{
+                       boxname << "Box" << _numBoxes;
+               }
+               _numBoxes++;
+               return boxname.str();
+       }
 
-       int wxVtkSceneManager::createGBlackBox(int x, int y, std::string packageName, std::string boxType)
+       //=========================================================================
+  
+       std::string wxVtkSceneManager::findANewNameForABox()
        {
-               int windowWidth=_baseView->GetRenWin()->GetSize()[0];
-               int windowHeight=_baseView->GetRenWin()->GetSize()[1];
+               std::string boxname=generateANewNameForABox();
 
-               int type = GBLACKBOX;
+               while (boxExist(boxname)==true)
+               {
+                       boxname=generateANewNameForABox();
+               } // while
+
+               return boxname;
+       }
+
+       //=========================================================================
+       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  
@@ -128,21 +250,18 @@ namespace bbtk
                
                //z value is not important yet, because it is only used a parallel projection
                double zz = 900;
-
+printf("EED  wxVtkSceneManager::createGBlackBox 900-450\n");
                _baseView->TransCoordScreenToWorld(xx,yy,zz);
                model->setInicPoint(xx,yy,zz);
                
-               _numBoxes++;
                std::stringstream stream;
                
-               if(_numBoxes<10)
-               {
-                       stream << "Box0" << _numBoxes;
-               }
-               else
-               {
-                       stream << "Box" << _numBoxes;
-               }
+               std::string newBoxName;
+               newBoxName = findANewNameForABox();
+                       
+               
+               stream << newBoxName;
+               
                std::string arraystring = stream.str();
 
                model->setBBTKName(arraystring);
@@ -190,6 +309,7 @@ namespace bbtk
                model->notifyObservers(_idManager);
                
                int newId = addObjectController(controller);
+
                return newId;
 
        }
@@ -198,24 +318,25 @@ 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;
+printf("EED  wxVtkSceneManager::createGComplexBoxInputPort 900-450\n");
 
                _baseView->TransCoordScreenToWorld(xx,yy,zz);
                model->setInicPoint(xx,yy,zz);
@@ -251,24 +372,26 @@ 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;
+               
+printf("EED  wxVtkSceneManager::createGComplexBoxOutputPort 900-450\n");
 
                _baseView->TransCoordScreenToWorld(xx,yy,zz);
                model->setInicPoint(xx,yy,zz);
@@ -325,9 +448,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);
                
@@ -348,7 +471,7 @@ namespace bbtk
 
                model->notifyObservers(_idManager);
 
-               int newId = addObjectController(controller);
+               addObjectController(controller);
 
                return (GPortController*)controller;
        }
@@ -360,12 +483,12 @@ namespace bbtk
                int type = GCONNECTOR;
 
                manualConnectorContourController* manContourControl     = new manualConnectorContourController();
-               manualConnectorContourView* manContourView      = new manualConnectorContourView();
-               manualContourModel* manContourModel     = new manualContourModel();
+               manualConnectorContourView* manContourView                      = new manualConnectorContourView();
+               manualContourModel* manContourModel                                     = new manualContourModel();
 
-               GConnectorController* connectorcontroller = new GConnectorController();                         
-               GConnectorModel* connectorModel = new GConnectorModel();
-               vtkGConnectorView* connectorView = new vtkGConnectorView();
+               GConnectorController* connectorcontroller                       = new GConnectorController();                           
+               GConnectorModel* connectorModel                                         = new GConnectorModel();
+               vtkGConnectorView* connectorView                                        = new vtkGConnectorView();
                connectorModel->setGObjectType(type);
 
                manContourModel->SetCloseContour(false);
@@ -462,10 +585,10 @@ namespace bbtk
                {
                        if(command == ADD_TO_SELECTED)
                        {
-                               GObjectController* cont = _controllers[idController];
+//EED                          GObjectController* cont = _controllers[idController];
 
                                bool foundID=false;
-                               for (int i=0; i<_selectedObjects.size() && foundID==false; i++)
+                               for (int i=0; i<(int)_selectedObjects.size() && foundID==false; i++)
                                {
                                        int id = _selectedObjects[i];
                                        if(id==idController)
@@ -488,9 +611,11 @@ namespace bbtk
                                
 
                                // The last one is the controller of the connector
-                               for(int i=0;i<_controllers.size();i++)
+                               std::map<int, GObjectController*>::iterator it2;
+
+                               for(it2 = _controllers.begin(); it2 != _controllers.end(); ++it2)
                                {
-                                       GObjectController* cont = _controllers[i];
+                                       GObjectController *cont = it2->second;
                                        if(cont->getGObjectType() == GPORT )
                                        {
                                                GPortModel* port = (GPortModel*)cont->getModel();
@@ -515,14 +640,14 @@ namespace bbtk
 
                                _selectedObjects.clear();
 
-                               createGConnector(startOutputPort);
+                               _idConnectionInCreation=createGConnector(startOutputPort);
 
                        }
                        else if(command == FIN_CREATION_CONTOUR && _worldState == INIT_CREATION_CONTOUR)
                        {                               
                                _worldState = NOTHING_HAPPENS;
-                               int id = _controllers.size()-1;
-                               GObjectController* cont = _controllers[id];                     
+                               //int id = _controllers.size()-1;
+                               GObjectController* cont = _controllers[_idConnectionInCreation];                        
                                GConnectorModel* modelContour = (GConnectorModel*)cont->getModel();
 
                                GObjectController* finPort = _controllers[idController];
@@ -536,9 +661,11 @@ namespace bbtk
                                manualConnectorContourView* connView = (manualConnectorContourView*)manCont->GetManualViewBaseContour();
                                connView->Refresh();
 
-                               for(int i=0;i<_controllers.size();i++)
+                               std::map<int, GObjectController*>::iterator it2;
+
+                               for(it2 = _controllers.begin(); it2 != _controllers.end(); ++it2)
                                {
-                                       GObjectController* cont = _controllers[i];
+                                       GObjectController *cont = it2->second;
                                        if(cont->getView()!=NULL)
                                        {
                                                cont->getView()->setState(NOTHING_HAPPENS);
@@ -556,6 +683,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);
@@ -563,7 +692,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];
@@ -594,25 +723,56 @@ namespace bbtk
                else if(_worldState == NOTHING_HAPPENS || _worldState == INIT_CREATION_CONTOUR)
                {
                        std::map<int, GObjectController*>::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+1 , pz+2 );
+                                               
+//ups4 EED Borrame             
+                                               // FillPortText
+                                               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) 
+               {
+                       updateStatusBar("");
                }
                
+               if (okPortMessage==false) 
+               {
+                       _textActor->SetScale(0.0001);
+                       _fillObjectActor->SetScale(0.0001);
+               }
+               
+
                return true;
        }
 
@@ -634,18 +794,18 @@ namespace bbtk
                                        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[lastId];
+                               //int lastId = _controllers.size()-1;
+                               GConnectorController *connector = (GConnectorController*)_controllers[_controllers.size()-1];
                                connector->removeFromScene();
                                unregisterController(connector);
-                               _controllers.erase(lastId);                     
+                               _controllers.erase(_controllers.size()-1);                      
 
                                for(it = _controllers.begin(); it != _controllers.end(); ++it)
                                {
@@ -653,23 +813,23 @@ namespace bbtk
                                        desc->SetActive(true);
                                        desc->getView()->setState(NOTHING_HAPPENS);
                                        desc->getModel()->notifyObservers(_idManager);
-                               }
-                       }
-               }
+                               } // for 
+                       } // isOverPort
+               } // _worldState
                
                if(_selectedObjects.size()!=0)
                {
-                       _worldState = DRAG_OBJECTS;
-                       _startDragging = true;
+                       _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];
                                cont->getView()->setState(DRAG);
                                cont->getModel()->notifyObservers(_idManager);
-                       }
-               }
+                       } // for
+               } // _selectedObjects
                
                
                
@@ -684,7 +844,7 @@ namespace bbtk
                {
                        _worldState = NOTHING_HAPPENS;
 
-                       for (int i = 0; i < _selectedObjects.size(); i++)
+                       for (int i = 0; i < (int)_selectedObjects.size(); i++)
                        {
                                int id = _selectedObjects[i];
                                GObjectController* cont = _controllers[id];
@@ -702,11 +862,11 @@ namespace bbtk
                if(_worldState==INIT_CREATION_CONTOUR)
                {
                        _worldState=NOTHING_HAPPENS;
-                       int lastId = _controllers.size()-1;
-                       GConnectorController *connector = (GConnectorController*)_controllers[lastId];
+                       //int lastId = _controllers.size()-1;
+                       GConnectorController *connector = (GConnectorController*)_controllers[_idConnectionInCreation];
                        connector->removeFromScene();
                        unregisterController(connector);
-                       _controllers.erase(lastId);                     
+                       _controllers.erase(_idConnectionInCreation);                    
 
                        std::map<int, GObjectController*>::iterator it;
                        for(it = _controllers.begin(); it != _controllers.end(); ++it)
@@ -719,7 +879,7 @@ namespace bbtk
                }
 
                        
-               for (int i = 0; i < _selectedObjects.size(); i++)
+               for (int i = 0; i < (int)_selectedObjects.size(); i++)
                {
                        int id = _selectedObjects[i];
                        GObjectController* cont = _controllers[id];
@@ -755,7 +915,7 @@ namespace bbtk
                        {
                                if(type==GBLACKBOX)
                                {
-                                       for (int i=0; i<_selectedObjects.size(); i++)
+                                       for (int i=0; i< (int)_selectedObjects.size(); i++)
                                        {
                                                int id = _selectedObjects[i];
                                                GObjectController* control = _controllers[id];
@@ -790,10 +950,15 @@ namespace bbtk
                {
                        if(_selectedObjects.size()>0)
                        {
-                               for(int i=0;i<_selectedObjects.size();i++)
+                               for(int i=0;i<(int)_selectedObjects.size();i++)
                                {
-                                       int id = _selectedObjects[i];
-                                       deleteObject(id);
+                                       int id = _selectedObjects[i];                                   
+                                       std::map<int,GObjectController*>::iterator it;
+                    it = _controllers.find(id);
+                                       if (it!=_controllers.end())
+                                       {
+                                               deleteObject(id);
+                                       }
                                }
                                _selectedObjects.clear();
                        }
@@ -804,6 +969,28 @@ namespace bbtk
 
        //=========================================================================
 
+       void wxVtkSceneManager::AddControlerToBeRemove(std::vector<int> *controllersToRemove, int id)
+       {
+               
+               int i;
+               bool ok=true;
+               for(i=0 ; i < (int)controllersToRemove->size() ; i++ )
+               {
+                       if (id == (*controllersToRemove)[i] )
+                       {
+                               ok=false;
+                       }
+               }
+               
+               if (ok==true)
+               {
+                  controllersToRemove->push_back( id );
+               }
+               
+       }
+       
+       //=========================================================================
+       
        void wxVtkSceneManager::deleteObject(int id)
        {
                GObjectController *control = _controllers[id];
@@ -817,9 +1004,9 @@ namespace bbtk
                        bool boxConnected = false;
 
                        // Add box input controllers to be removed
-                       for(int i = 0;i<inputs.size();i++)
+                       for(int i = 0;i< (int)inputs.size();i++)
                        {
-                               controllersToRemove.push_back(inputs[i]->getObjectId());
+                               AddControlerToBeRemove( &controllersToRemove, inputs[i]->getObjectId() );
                                if(inputs[i]->isConnected())
                                {
                                        boxConnected = true;
@@ -829,9 +1016,9 @@ namespace bbtk
                        std::vector<GPortModel*> outputs = bbmod->getOutputPorts();
 
                        // Add box output controllers to be removed
-                       for(int i = 0;i<outputs.size();i++)
+                       for(int i = 0;i<(int)outputs.size();i++)
                        {
-                               controllersToRemove.push_back(outputs[i]->getObjectId());
+                               AddControlerToBeRemove( &controllersToRemove, outputs[i]->getObjectId() );
                                if(outputs[i]->isConnected())
                                {
                                        boxConnected = true;
@@ -849,34 +1036,39 @@ namespace bbtk
                                        GConnectorModel *conMod = (GConnectorModel*)cont->getModel();
                                        if(conMod->getStartPort()!=NULL && conMod->getStartPort()->getParentBox()->getObjectId() == bbmod->getObjectId())
                                        {
-                                               controllersToRemove.push_back(conMod->getObjectId());
+                                               AddControlerToBeRemove( &controllersToRemove, conMod->getObjectId() );
                                        }
                                        if(conMod->getEndPort()!=NULL && conMod->getEndPort()->getParentBox()->getObjectId() == bbmod->getObjectId())
                                        {
-                                               controllersToRemove.push_back(conMod->getObjectId());
+                                               AddControlerToBeRemove( &controllersToRemove, conMod->getObjectId() );
                                        }
                                }
                        }
 
                        // Add box controller to be removed
-                       controllersToRemove.push_back(bbmod->getObjectId());
+                       AddControlerToBeRemove( &controllersToRemove, bbmod->getObjectId() );
                }
                else if(control->getGObjectType()==GCONNECTOR)
                {                       
                        GConnectorModel *conMod = (GConnectorModel*)control->getModel();
-                       controllersToRemove.push_back(conMod->getObjectId());
-               }
-
-               for(int i = 0;i<controllersToRemove.size();i++)
-               {
-                       int id = controllersToRemove[i];
-                       GObjectController *cont = _controllers[id];                     
-                       cont->removeFromScene();
-                       unregisterController((InteractorStyleMaracas*)cont);                    
-                       _controllers.erase(id);
+                       AddControlerToBeRemove( &controllersToRemove, conMod->getObjectId() );
                }
 
+               
+               std::map<int,GObjectController*>::iterator it;
 
+               for(int i = 0;i<(int)controllersToRemove.size();i++)
+               {
+                       int key = controllersToRemove[i];
+                       it = _controllers.find( key );
+                       GObjectController *cont = _controllers[ key ];
+                       if(cont!=NULL)
+                       {
+                               cont->removeFromScene();
+                               unregisterController((InteractorStyleMaracas*)cont);                    
+                               _controllers.erase(it);
+                       }//if
+               }// for
        }
 
        //=========================================================================
@@ -917,7 +1109,7 @@ namespace bbtk
                                
                                std::string pkg = mod->getBBTKPackage();
                                bool existsPkg = false;
-                               for(int t = 0;t<packages.size() && existsPkg == false;t++)
+                               for(int t = 0;t< (int)packages.size() && existsPkg == false;t++)
                                {
                                        if(packages[t]==pkg)
                                        {
@@ -946,21 +1138,23 @@ namespace bbtk
                std::string script = "";
                script+="# BBTK GEditor Script\n";
                script+="# ----------------------\n";
+               script+="\n";
                if(existsExec)
                {
                        script+="include std\n"; // EED
                        script+="include itkvtk\n"; // EED
                        int i;
-                       for(i = 0; i<packages.size();i++)
+                       for(i = 0; i< (int)packages.size();i++)
                        {
                                script+="include ";
                                script+=packages[i];
                                script+="\n";
                        }
+                       script+="\n";
 
                        // script+="include std\n"; // JPR
 
-                       for(i = 0; i<boxes.size();i++)
+                       for(i = 0; i < (int)boxes.size();i++)
                        {
                                script+="new ";
                                int id = boxes[i];
@@ -973,12 +1167,12 @@ namespace bbtk
                                script+="\n";
 
                                std::vector<GPortModel*> inputs = model->getInputPorts();
-                               for(int j = 0; j<inputs.size();j++)
+                               for(int j = 0; j < (int)inputs.size();j++)
                                {
                                        GPortModel* inputPort = inputs[j];
                                        if(inputPort->isValueSet())
                                        {
-                                               script+="set ";
+                                               script+="  set ";
                                                script+=model->getBBTKName();
                                                script+=".";
                                                script+=inputPort->getBBTKName();
@@ -987,10 +1181,13 @@ namespace bbtk
                                                script+="\n";
                                        }
                                }
+                               script+="\n";
 
                        }
 
-                       for(i = 0; i<connections.size();i++)
+                       script+="\n";
+
+                       for(i = 0; i<(int)connections.size();i++)
                        {
                                script+="connect ";
                                int id = connections[i];
@@ -1014,7 +1211,8 @@ namespace bbtk
                                script+="\n";
                        }
 
-                       for(i = 0; i<execBoxes.size();i++)
+                       script+="\n";
+                       for(i = 0; i<(int)execBoxes.size();i++)
                        {
                                script+="exec ";
                                int id = execBoxes[i];
@@ -1053,7 +1251,7 @@ namespace bbtk
                                
                                std::string pkg = mod->getBBTKPackage();
                                bool existsPkg = false;
-                               for(int t = 0;t<packages.size() && existsPkg == false;t++)
+                               for(int t = 0;t<(int)packages.size() && existsPkg == false;t++)
                                {
                                        if(packages[t]==pkg)
                                        {
@@ -1083,17 +1281,19 @@ namespace bbtk
                script+="include std\n";    // EED
                script+="include itkvtk\n"; // EED
                int i;
-               for(i = 0; i<packages.size();i++)
+               for(i = 0; i<(int)packages.size();i++)
                {
                        script+="include ";
                        script+=packages[i];
                        script+="\n";
                }
+               script+="\n";
 
                // Definition of a complex box
                script+="define ";
                script+=cbName;
                script+="\n";
+               script+="\n";
 
                script+="author \" ";
                script+=cbAuthor;
@@ -1102,9 +1302,10 @@ namespace bbtk
                script+="description \" ";
                script+=cbDescription;
                script+="\"\n";
+               script+="\n";
 
                // Create boxes
-               for(i = 0; i<boxes.size();i++)
+               for(i = 0; i<(int)boxes.size();i++)
                {
                        script+="new ";
                        int id = boxes[i];
@@ -1117,12 +1318,12 @@ namespace bbtk
                        script+="\n";
 
                                std::vector<GPortModel*> inputs = model->getInputPorts();
-                               for(int j = 0; j<inputs.size();j++)
+                               for(int j = 0; j<(int)inputs.size();j++)
                                {
                                        GPortModel* inputPort = inputs[j];
                                        if(inputPort->isValueSet())
                                        {
-                                               script+="set ";
+                                               script+="  set ";
                                                script+=model->getBBTKName();
                                                script+=".";
                                                script+=inputPort->getBBTKName();
@@ -1131,6 +1332,7 @@ namespace bbtk
                                                script+="\n";
                                        }
                                }
+                               script+="\n";
 
                        }
 
@@ -1138,8 +1340,9 @@ namespace bbtk
 
                        std::string complexInputs="";
                        std::string complexOutputs="";
+                       script+="\n";
 
-                       for(i = 0; i<connections.size();i++)
+                       for(i = 0; i<(int)connections.size();i++)
                        {
                                int id = connections[i];
                                GObjectController *control = _controllers[id];
@@ -1200,7 +1403,9 @@ namespace bbtk
                                }
                        }
 
-                       for(i = 0; i<execBoxes.size();i++)
+                   script+="\n";
+               
+                       for(i = 0; i<(int)execBoxes.size();i++)
                        {
                                script+="exec ";
                                int id = execBoxes[i];
@@ -1265,7 +1470,7 @@ namespace bbtk
        //=========================================================================
 
        void wxVtkSceneManager::saveDiagram(std::string &content)
-       {               
+       {
                char buffer [50];
 
                //Print info IF COMPLEX BOX
@@ -1303,7 +1508,7 @@ namespace bbtk
                                GObjectController *cont = _controllers[id];
                                cont->getModel()->save(content);
                        }
-               }
+               } // _isComplexBox
                else
                {
                        content+="FALSE\n";
@@ -1370,7 +1575,7 @@ namespace bbtk
 
                        //----------
                        getline(inputStream,line);//COMPLEX_BOX:TRUE|FALSE
-                       char complex[15];
+                       char complex[30];
                        strcpy( complex, line.c_str() );
                        result = strtok( complex, delims );
                        result = strtok( NULL, delims );
@@ -1384,7 +1589,7 @@ namespace bbtk
                                //- COMPLEX INPUT PORTS
                                //-----------------------
                                getline(inputStream,line);//COMPLEXINPUTS:num
-                               char inputs[18];
+                               char inputs[30];
                                strcpy( inputs, line.c_str() );
                                result = strtok( inputs, delims );
                                result = strtok( NULL, delims );
@@ -1421,12 +1626,10 @@ namespace bbtk
 
                                        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);
-                               }
+                                       configGComBoxInputOutputPort(true, inputPortName,xIn,yIn,zIn);
+
+                                       
+                               } // for input complex box
 
 
                                //-----------------------
@@ -1434,7 +1637,7 @@ namespace bbtk
                                //-----------------------
 
                                getline(inputStream,line);//COMPLEXOUTPUTS:num
-                               char outputs[18];
+                               char outputs[30];
                                strcpy( outputs, line.c_str() );
                                result = strtok( outputs, delims );
                                result = strtok( NULL, delims );
@@ -1471,14 +1674,11 @@ 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);
 
-                       }
+                               } // for output complex box
+
+                       } // complex box
 
                        //----------
                        getline(inputStream,line);//BOXES:num
@@ -1496,7 +1696,7 @@ namespace bbtk
                                //----------
                                getline(inputStream,line);//BOX
                                getline(inputStream,line);//package:type:name
-                               char box[100];
+                               char box[150];
                                strcpy( box, line.c_str() );
                                result = strtok( box, delims );//package
                                std::string package(result);
@@ -1549,28 +1749,26 @@ 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);
+                                       boxExecutable= true;
                                }
-                               else if(isExec=="FALSE")
-                               {
-                                       bbmod->setExecutable(false);
-                               }
-                                                       
+                               
+                               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();
+
+                               
                                //----------
                                getline(inputStream,line);//PORT o FIN_BOX
                                std::string port=line.substr(0,4);
                                while(port=="PORT")
                                {
                                        getline(inputStream,line);//name:value
-                                       char poort[20];
+                                       char poort[150];
                                        strcpy( poort, line.c_str() );
                                        result = strtok( poort, delims );//name
                                        std::string name(result);
@@ -1581,15 +1779,15 @@ namespace bbtk
 
                                        getline(inputStream,line);//PORT o FIN_BOX
                                        port=line.substr(0,4);
-                               }               
+                               } // while              
 
-                               bbmod->notifyObservers(_idManager);
-                       }
+//EED                          bbmod->notifyObservers(_idManager);
+                       } // for boxes
 
                        /// CONNECTIONS
                        //----------
                        getline(inputStream,line);//CONNECTIONS:num
-                       char conns[15];
+                       char conns[30];
                        strcpy( conns, line.c_str() );
                        result = strtok( conns, delims );
                        result = strtok( NULL, delims );
@@ -1604,7 +1802,7 @@ namespace bbtk
                                getline(inputStream,line);//CONNECTION
                                getline(inputStream,line);//Startbox.PortName:EndBox.PortName
 
-                               char connec[100];
+                               char connec[200];
                                strcpy( connec, line.c_str() );
                                result = strtok( connec, delims );
                                std::string nameStartBox(result);
@@ -1615,68 +1813,135 @@ namespace bbtk
                                result = strtok( NULL, delims );
                                std::string nameEndPort(result);
 
-                               std::vector<int> lstB = getBlackBoxes();
-                               
-                               GPortModel *startP=NULL;
-                               GPortModel *endP=NULL;                          
-                               for(int j = 0;j<lstB.size();j++)
-                               {
-                                       int idB = lstB[j];
-                                       GBlackBoxModel *bbMod = (GBlackBoxModel*)_controllers[idB]->getModel();
-                                       if(_controllers[idB]->getModel()->getBBTKName()==nameStartBox)
-                                       {                                               
-                                               startP = bbMod->getOutputPort(nameStartPort);
-                                       }
-                                       else if(_controllers[idB]->getModel()->getBBTKName()==nameEndBox)
-                                       {
-                                               endP = bbMod->getInputPort(nameEndPort);
-                                       }
-                               }
+                               configGConnetion(nameStartBox, nameStartPort, nameEndBox, nameEndPort);
+                       } // for numConns
+                       
+        } // start
+
+       }
+       //=========================================================================
 
-                               if(_isComplexBox)
+       
+       
+       //=========================================================================     
+       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<int> 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<int> lstInputs = getComplexInputPorts();
+                       for(j = 0;j<(int)lstInputs.size();j++)
+                       {
+                               idB             = lstInputs[j];
+                               bMod    = (GBoxModel*)_controllers[idB]->getModel();
+                               if(_controllers[idB]->getModel()->getBBTKName()==boxname)
                                {
-                                       if(startP==NULL)
-                                       {
-                                               std::vector<int> lstInputs = getComplexInputPorts();
-                                               for(int j = 0;j<lstInputs.size();j++)
-                                               {
-                                                       int idB = lstInputs[j];
-                                                       GBoxModel *cbMod = (GBoxModel*)_controllers[idB]->getModel();
-                                                       if(_controllers[idB]->getModel()->getBBTKName()==nameStartBox)
-                                                       {                                               
-                                                               startP = cbMod->getOutputPort(nameStartPort);
-                                                       }
-                                               }
-                                       }
+                                       boxModel = bMod;
+                               }  
+                       } // for
+                       
+                       std::vector<int> 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
 
-                                       if(endP==NULL)
-                                       {
-                                               std::vector<int> lstOutputs = getComplexOutputPorts();
-                                               for(int j = 0;j<lstOutputs.size();j++)
-                                               {
-                                                       int idB = lstOutputs[j];
-                                                       GBoxModel *cbMod = (GBoxModel*)_controllers[idB]->getModel();
-                                                       if(_controllers[idB]->getModel()->getBBTKName()==nameEndBox)
-                                                       {                                               
-                                                               endP = cbMod->getInputPort(nameEndPort);
-                                                       }
-                                               }
-                                       }
-                               }
-                                                               
-                               int idCon = createGConnector(startP);
-                               _worldState = NOTHING_HAPPENS;
-                               GConnectorController *tempp = (GConnectorController*)_controllers[idCon]; 
+               return boxModel;
+       }
+       
+       //=========================================================================
 
-                               GConnectorModel *conMod = (GConnectorModel*)tempp->getModel();
-                               vtkGConnectorView *conView = (vtkGConnectorView*)tempp->getView();
-                               tempp->endContourCreation();
-                               conMod->setEndPort(endP);                                       
-                               conView->updateStartEndPoints();
 
-                       }
-        }
+       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 );
+
+               
+               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<int, GObjectController*>::iterator it;
+               for(it = _controllers.begin(); it != _controllers.end(); ++it)
+               {
+                       GObjectController *cont = it->second;           
+                       if(cont->getModel()->getBBTKName()==boxname)
+                       {
+                               ok=true;
+                       }
+               }
+               return ok;
        }
 
        //=========================================================================
@@ -1760,7 +2025,7 @@ namespace bbtk
        {
                _isComplexBox=val;
        }
-
        //=========================================================================
 
        int wxVtkSceneManager::addObjectController(GObjectController* objController)
@@ -1769,9 +2034,10 @@ namespace bbtk
                registerController((InteractorStyleMaracas*) objController);
 
                //Add the object to the objects list 
-               int newId = _controllers.size();
+               int newId = _contLastId;//_controllers.size();
                objController->setId(newId);
                _controllers[newId] = objController;
+               _contLastId++;
                return newId;
        }
 
@@ -1815,8 +2081,7 @@ namespace bbtk
                                {                                       
                                        int ID = cont->getId();
                                        mapSelected[ID]=cont;
-                               }
-                               
+                               }                               
                        }
                }
                return mapSelected;
@@ -1864,7 +2129,7 @@ namespace bbtk
                        
                }
                
-               for(int i = 0 ;i<connections.size();i++)
+               for(int i = 0 ;i<(int)connections.size();i++)
                {
                        int objId = connections[i];
                        GObjectController *cont = objectsMap[objId];                    
@@ -1911,11 +2176,11 @@ namespace bbtk
                        std::vector<int> newInputConnections = newBox->getConnectedInputs();
                        std::vector<int> newOutputConnections = newBox->getConnectedOutputs();
 
-                       for(int k = 0; k<oldInputConnections.size();k++)
+                       for(int k = 0; k<(int)oldInputConnections.size();k++)
                        {
                                bool exist=false;
-                               int toCreate=-1;
-                               for(int l = 0; l<newInputConnections.size() && !exist;l++)
+//EED                          int toCreate=-1;
+                               for(int l = 0; l<(int)newInputConnections.size() && !exist;l++)
                                {
                                        if(oldInputConnections[k]==newInputConnections[l])
                                        {
@@ -1954,11 +2219,11 @@ namespace bbtk
                        }
                        
 
-                       for(int k = 0; k<oldOutputConnections.size();k++)
+                       for(int k = 0; k<(int)oldOutputConnections.size();k++)
                        {
                                bool exist=false;
-                               int toCreate=-1;
-                               for(int l = 0; l<newOutputConnections.size() && !exist;l++)
+//EED                          int toCreate=-1;
+                               for(int l = 0; l<(int)newOutputConnections.size() && !exist;l++)
                                {
                                        if(oldOutputConnections[k]==newOutputConnections[l])
                                        {