]> Creatis software - bbtkGEditor.git/blobdiff - lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx
#3249 Change FontSize - Box graphic scale
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsWxGUIEditorGraphic / wxVtkSceneManager.cxx
index 002e5895014dc0ed85cfa6f5b4c7862632469d4d..960cdad62c69741d83f8cc1861af317851a26dab 100644 (file)
@@ -71,8 +71,11 @@ namespace bbtk {
        
 // EED 15 oct 2012  wxVtkSceneManager::wxVtkSceneManager(wxGEditorTabPanel *parent, wxVtk3DBaseView *baseView, int idManager,Factory::Pointer bbtkfactory) 
        
+       
 wxVtkSceneManager::wxVtkSceneManager(wxGEditorTabPanel *parent, wxVtk3DBaseView *baseView, int idManager,Factory::Pointer bbtkfactory) 
 {
+       
+       
        _cbName                                 = "ComplexBoxName";
        _cbPackageName                  = "PackageName";
        _Author                                 = "Author ??";
@@ -116,7 +119,6 @@ wxVtkSceneManager::wxVtkSceneManager(wxGEditorTabPanel *parent, wxVtk3DBaseView
 
 void wxVtkSceneManager::disconnectDrop() 
 {
-       printf("EED %p ~wxVtkSceneManager::disconnectDrop()\n", this);
        //EED02JUIN2010         _baseView->GetWxVTKRenderWindowInteractor()->SetDropTarget(NULL);
        //      _baseView->GetWxVTKRenderWindowInteractor()->SetDropTarget( new tmpClasswxTextDropTarget() );
 }
@@ -126,10 +128,8 @@ void wxVtkSceneManager::disconnectDrop()
 wxVtkSceneManager::~wxVtkSceneManager() 
 {
        //FCY memory leaks
-       printf("EED %p ~wxVtkSceneManager() START\n", this);
        disconnectDrop();
        delete _baseView;
-       printf("EED %p ~wxVtkSceneManager() END\n", this);
 }
 
 //=========================================================================
@@ -137,47 +137,41 @@ wxVtkSceneManager::~wxVtkSceneManager()
 void wxVtkSceneManager::configureBaseView() 
 {
        vtkInteractorStyleBaseView2D *interactorstylebaseview = vtkInteractorStyleBaseView2D::New();
-
        _baseView->SetInteractorStyleBaseView(interactorstylebaseview);
-
        // Important to activate the 2D interaction system
-       wxVTKRenderWindowInteractor *iren =     _baseView->GetWxVTKRenderWindowInteractor();
+       crea::wxVTKRenderWindowInteractor *iren =       _baseView->GetWxVTKRenderWindowInteractor();
        interactorstylebaseview->SetInteractor(iren);
        iren->SetInteractorStyle(interactorstylebaseview);
        interactorstylebaseview->SetwxVtkBaseView(_baseView);
-
        _baseView->GetRenderer()->GetActiveCamera()->ParallelProjectionOn();
        _baseView->GetRenderer()->ResetCamera(-100, 100, -100, 100, -1000, 1000);
-       _baseView->GetRenderer()->GetActiveCamera()->Zoom(10);
-
-
+       _baseView->GetRenderer()->GetActiveCamera()->Zoom(20);
        _baseView->GetRenderer()->SetBackground(0.9, 0.9, 0.9);
        _baseView->GetRenderer()->GradientBackgroundOn();
-
        // Actos Port_Text
        _textActor = vtkTextActor3D::New();
 //     _textActor = vtkTextActor::New();
        _textActor->SetPosition(-9999, -9999, GPOSITION_Z);
        _textActor->SetInput("<void>");
-       _textActor->GetTextProperty()->SetFontSize(60);
+//EED 2022-01-16
+//    _textActor->GetTextProperty()->SetFontSize(60);
+       _textActor->GetTextProperty()->SetFontSize(40);
        _textActor->GetTextProperty()->BoldOn();
+    _textActor->GetTextProperty()->SetFontFamilyToArial();
+    _textActor->GetTextProperty()->ShadowOff();
        _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 = GPOSITION_Z;
+       double xInic            = 0;
+       double yInic            = 0;
+       double zInic            = GPOSITION_Z;
+       vtkPolygon *aPolygon    = vtkPolygon::New();
+       _fillObjectActor        = vtkActor::New();
+       _pts                    = vtkPoints::New();
 
-       vtkPolygon *aPolygon = vtkPolygon::New();
-       _fillObjectActor = vtkActor::New();
-
-       _pts = vtkPoints::New();
-
-       double w = 100, h = 10, b = h / 15, t = 3;
+/*
+    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);
@@ -204,25 +198,43 @@ void wxVtkSceneManager::configureBaseView()
        _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);
+    }
+*/
 
-       aPolygon->GetPointIds()->SetNumberOfIds(21);
-       for (int i = 0; i < 21; i++) {
+    double w = BOX_WIDTH, h = BOX_HEIGHT, t = PORT_HEIGHT;
+    _pts->SetNumberOfPoints(7);
+    _pts->InsertPoint(0, xInic + t/2.0  , yInic + t     , zInic );
+    _pts->InsertPoint(1, xInic + w      , yInic + t     , zInic );
+    _pts->InsertPoint(2, xInic + w      , yInic + t + h , zInic );
+    _pts->InsertPoint(3, xInic - t*1.5  , yInic + t + h , zInic );
+    _pts->InsertPoint(4, xInic - t*1.5  , yInic + t     , zInic );
+    _pts->InsertPoint(5, xInic - t/2    , yInic + t     , zInic );
+    _pts->InsertPoint(6, xInic          , yInic         , zInic );
+    aPolygon->GetPointIds()->SetNumberOfIds(8);
+       for (int i = 0; i < 8; i++)
+    {
                aPolygon->GetPointIds()->SetId(i, i);
+        if (i==7) aPolygon->GetPointIds()->SetId(i, 0);
        }
-
        vtkUnstructuredGrid *aPolygonGrid = vtkUnstructuredGrid::New();
        aPolygonGrid->Allocate(1, 1);
-       aPolygonGrid->InsertNextCell(aPolygon->GetCellType(),
-                       aPolygon->GetPointIds());
+       aPolygonGrid->InsertNextCell(aPolygon->GetCellType(),aPolygon->GetPointIds());
        aPolygonGrid->SetPoints(_pts);
        _aPolygonMapper = vtkDataSetMapper::New();
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
        _aPolygonMapper->SetInput(aPolygonGrid);
+#else
+       _aPolygonMapper->SetInputData(aPolygonGrid);
+#endif
        _fillObjectActor->SetMapper(_aPolygonMapper);
-       _fillObjectActor->GetProperty()->SetColor(PORTFILL_NH_R, PORTFILL_NH_G,
-                       PORTFILL_NH_B);
+       _fillObjectActor->GetProperty()->SetColor(PORTFILL_NH_R, PORTFILL_NH_G,PORTFILL_NH_B);
        _fillObjectActor->GetProperty()->SetOpacity(0);
        _aPolygonMapper->Modified();
-
        _baseView->GetRenderer()->AddActor(_fillObjectActor);
 }
 
@@ -329,14 +341,28 @@ int wxVtkSceneManager::createGBlackBox(int x, int y, std::string packageName,std
        model->addObserver(view);
        model->addObserver(this);
 
+
+//EED2017 change order
+       //Associates the view with the correspondent renderer and the  model.
+       //(NOTE: Refresh is only made by the view)
+       view->setModel(model);
+       view->setBaseView(_baseView);
+
+       //Associates the controller with the correspondent model and view
+       controller->setModelAndView(model, view);
+
+
        //Iterate and create the input ports
        std::map<std::string, BlackBoxInputDescriptor*> descriptorInMap =
                        descriptor->GetInputDescriptorMap();
        std::map<std::string, BlackBoxInputDescriptor*>::iterator itInput;
        int i = 0;
-       for (itInput = descriptorInMap.begin(); itInput != descriptorInMap.end(); ++itInput) {
+       for (itInput = descriptorInMap.begin(); itInput != descriptorInMap.end(); ++itInput) 
+       {
                BlackBoxInputDescriptor *desc = itInput->second;
-               createGInputPort(GINPUTPORT, i, model, desc);
+//EED2017-04-07
+//             createGInputPort(GINPUTPORT, i, model, desc);
+               createGInputPort(GINPUTPORT, i, controller, desc);
                i++;
        }
 
@@ -345,26 +371,20 @@ int wxVtkSceneManager::createGBlackBox(int x, int y, std::string packageName,std
                        descriptor->GetOutputDescriptorMap();
        std::map<std::string, BlackBoxOutputDescriptor*>::iterator itOutput;
        i = 0;
-       for (itOutput = descriptorOutMap.begin(); itOutput
-                       != descriptorOutMap.end(); ++itOutput) {
+       for (itOutput = descriptorOutMap.begin(); itOutput!= descriptorOutMap.end(); ++itOutput) 
+       {
                BlackBoxOutputDescriptor *desc = itOutput->second;
-               createGOutputPort(GOUTPUTPORT, i, model, desc);
+//EED2017-04-07
+//             createGOutputPort(GOUTPUTPORT, i, model, desc);
+               createGOutputPort(GOUTPUTPORT, i, controller, desc);
                i++;
        }
 
-       //Associates the view with the correspondent renderer and the  model.
-       //(NOTE: Refresh is only made by the view)
-       view->setModel(model);
-       view->setBaseView(_baseView);
-
+//EED2017 change order
        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;
@@ -479,21 +499,35 @@ int wxVtkSceneManager::createGComplexBoxOutputPort(std::string outputName) {
 
 //=========================================================================
 
-int wxVtkSceneManager::createGInputPort(int portType, int posinBox, GBoxModel *blackBox, BlackBoxInputDescriptor *desc) 
+//EED2017-04-08
+//int wxVtkSceneManager::createGInputPort(int portType, int posinBox, GBoxModel *blackBox, BlackBoxInputDescriptor *desc) 
+int wxVtkSceneManager::createGInputPort(int portType, int posinBox, GObjectController *gBoxControler, BlackBoxInputDescriptor *desc) 
 {
+       GBoxModel *blackBox=(GBoxModel*)gBoxControler->getModel();
        GPortController* portController = createGPort(portType, desc->GetName(),
                        desc->GetTypeName(), desc->GetDescription(), posinBox, blackBox);
-       blackBox->addInputPort((GPortModel*) portController->getModel());
+       blackBox->addInputPort( (GPortModel*)portController->getModel() );
+
+       vtkGBoxView *vtkgboxView=(vtkGBoxView*)gBoxControler->getView();
+       vtkgboxView->addInputPort( (vtkGPortView*)portController->getView() );
+
        return portController->getId();
 }
 
 //=========================================================================
 
-int wxVtkSceneManager::createGOutputPort(int portType, int posinBox,GBoxModel *blackBox, BlackBoxOutputDescriptor *desc) 
+//EED2017-04-08
+//int wxVtkSceneManager::createGOutputPort(int portType, int posinBox,GBoxModel *blackBox, BlackBoxOutputDescriptor *desc) 
+int wxVtkSceneManager::createGOutputPort(int portType, int posinBox,GObjectController *gBoxControler, BlackBoxOutputDescriptor *desc) 
        {
+       GBoxModel *blackBox=(GBoxModel*)gBoxControler->getModel();
        GPortController* portController = createGPort(portType, desc->GetName(),
                        desc->GetTypeName(),desc->GetDescription(), posinBox, blackBox);
        blackBox->addOutputPort((GPortModel*) portController->getModel());
+
+       vtkGBoxView *vtkgboxView=(vtkGBoxView*)gBoxControler->getView();
+       vtkgboxView->addOutputPort( (vtkGPortView*)portController->getView() );
+
        return portController->getId();
 }
 
@@ -504,43 +538,28 @@ GPortController* wxVtkSceneManager::createGPort(int portType,std::string bbtkNam
        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);
-
        model->setBBTKType(bbtkType);
        model->setBBTKName(bbtkName);
        model->setBBTKDescription(bbtkDescription);
-
        model->addObserver(view);
        model->addObserver(this);
-
        //Associates the view with the correspondent renderer and the  model.
        //(NOTE: Refresh is only made by the view)
        view->setModel(model);
        view->setBaseView(_baseView);
-
 //EED017       view->initVtkObjects();
        view->createVtkObjects();
 //  view->addVtkActors();
 
-
        //Associates the controller with the correspondent model and view
        controller->setModelAndView(model, view);
-
        model->notifyObservers(_idManager);
-
        addObjectController(controller);
-
        return (GPortController*) controller;
-
 }
 
 //=========================================================================
@@ -577,8 +596,11 @@ int wxVtkSceneManager::createGConnector(GPortModel* startPort)
          * @param WidthLine  
          */
  //EED2017
-        manContourView->SetWidthLine( 3 ) ;
-       manContourView->SetShowText(false);
+//        manContourView->SetWidthLine( 3 ) ;
+//EED 2022-01-16
+          manContourView->SetWidthLine( 1 ) ;
+
+    manContourView->SetShowText(false);
 
        manContourControl->SetModelView(manContourModel, manContourView);
 
@@ -711,10 +733,10 @@ void wxVtkSceneManager::update(int idController, int command) {
                                 // Highliht element 
                                 obc->getView( )->setState( POSSIBLE_CONNECTION ) ;                             
                                 //obc->getView( )->setState( HIGHLIGHTED ) ;
-                            }
-                        }
-                    }
-                }
+                            } // if obc_type
+                        } // for c_it
+                    } // if
+                } // if iter
 
                 // EO JGRR & CM WH  
                      
@@ -776,7 +798,6 @@ void wxVtkSceneManager::update(int idController, int command) {
                                     if ((obc_type == GPORT) && (obc_state == SELECTED_POSSIBLE_CONNECTION)) {
                                         // Change element to connected state
                                         obc->getView()->setState(HIGHLIGHTED);
-
                                     }
 
                                 }
@@ -813,7 +834,7 @@ bool wxVtkSceneManager::OnMouseMove()
        int X, Y;
        bool okStatusMessage    = false;
        bool okPortMessage      = false;
-       wxVTKRenderWindowInteractor *wxVTKiren;
+       crea::wxVTKRenderWindowInteractor *wxVTKiren;
        wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
        wxVTKiren->GetEventPosition(X, Y);
 
@@ -866,25 +887,33 @@ bool wxVtkSceneManager::OnMouseMove()
                                        // PortText
                                        if ( ( _bugTextActor_text==desc->getStatusText() ) || (_bugTextActor_status==0) )
                                        {
-                                               _bugTextActor_status    = 1;
-                                               okPortMessage           = true;
-                                               py                      = py + 5;
-                                               _textActor->SetScale(0.1);
-                                               std::string tmp = desc->getStatusText()+"\n";
+                        _bugTextActor_status   = 1;
+                                               okPortMessage               = true;
+//EED 2022-01-16
+//                        py                      = py + 5;
+//                                             _textActor->SetScale(0.1);
+//                        py                         = py + 5*0.5;
+                        _textActor->SetScale(0.05,0.05,1);
+
+                                               std::string tmp         = desc->getStatusText()+"\n";
                                                _textActor->SetInput( tmp.c_str() );
-                                               _textActor->SetPosition(px - 25, py + 1, pz + 2);
+//                      _textActor->SetPosition(px - 25, py + 1, pz + 2);
+//                      _textActor->SetPosition(px  , py-PORT_HEIGHT/4 , pz + 2);
+                                               _textActor->SetPosition(px  , py-PORT_HEIGHT , pz + 2);
                                                _textActor->Modified();
                                                // FillPortText
-                                               px                      = px - 33;
-                                               //py = py;
-                                               _fillObjectActor->SetScale(1);
-                                               _fillObjectActor->GetProperty()->SetOpacity(0.50);
-                                               _fillObjectActor->SetPosition(px, py, 1);
+//EED 2022-01-16
+//                        px                         = px - 33;
+                        _fillObjectActor->SetScale(1);
+//                        px                         = px - 33*0.7;
+//                                             _fillObjectActor->SetScale(0.7,0.5,1);
+                                               _fillObjectActor->GetProperty()->SetOpacity(0.75);
+                                               _fillObjectActor->SetPosition( px, py + PORT_HEIGHT/2.0 , 1);
                                                _aPolygonMapper->Modified();
                                        } else {
-                                               _bugTextActor_status    = 2;
+                                               _bugTextActor_status= 2;
                                        } //  _bugTextActor_tex
-                                       _bugTextActor_text              = desc->getStatusText();
+                                       _bugTextActor_text                  = desc->getStatusText();
 
                                } // if GPORT
                        }  //if state
@@ -1052,7 +1081,7 @@ bool wxVtkSceneManager::OnMiddleButtonUp() {
 GObjectController *wxVtkSceneManager::GetGBlackBoxControlerPointedByMouse() {
        GObjectController *result = NULL;
        int X, Y;
-       wxVTKRenderWindowInteractor *wxVTKiren;
+       crea::wxVTKRenderWindowInteractor *wxVTKiren;
        wxVTKiren
                        = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
        wxVTKiren->GetEventPosition(X, Y);
@@ -1090,47 +1119,6 @@ bool wxVtkSceneManager::OnLeftDClick() {
                UnSelectBlackBoxes();
                _parent->editBlackBox((GBlackBoxModel*) cont->getModel());
        }
-
-       /*EED Borrame
-
-        int X,Y;
-        wxVTKRenderWindowInteractor *wxVTKiren;
-        wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
-        wxVTKiren->GetEventPosition(X,Y);
-
-        std::map<int, GObjectController*>::iterator it;
-
-        bool clickOnObject = false;
-
-        for(it = _controllers.begin(); it != _controllers.end() && clickOnObject==false; ++it)
-        {
-        GObjectController *cont = it->second;
-        int type = cont->getGObjectType();
-
-        if(cont->getView()->isPointInside(X,Y))
-        {
-        if(type==GBLACKBOX)
-        {
-        for (int i=0; i< (int)_selectedObjects.size(); i++)
-        {
-        int id = _selectedObjects[i];
-        GObjectController* control = _controllers[id];
-        control->getView()->setState(NOTHING_HAPPENS);
-        }
-        _selectedObjects.clear();
-
-        GBlackBoxModel *bbmodel = (GBlackBoxModel*)cont->getModel();
-        _parent->editBlackBox(bbmodel);
-        }
-        clickOnObject = true;
-        }
-        }
-
-        if(clickOnObject==false)
-        {
-        //_parent->editDiagramParameters(this);
-        }
-        */
        return true;
 }
 
@@ -1175,13 +1163,9 @@ bool wxVtkSceneManager::OnChar()
                        _parent->saveTempandUpdate("delete object");
        }// if keyCode
        
-       /// Duplicate 
-#ifdef MACOSX
-       if((keyCode==0) && (ctrlkey==1)) {                
-#else
+       // Duplicate
        ctrlkey+=keyCode;
        if(ctrlkey==5){                
-#endif
                if(_selectedObjects.size()){
                        std::cout<<"objects to copy :";
                        for(int i=0;i<_selectedObjects.size();i++)
@@ -1481,14 +1465,14 @@ std::string wxVtkSceneManager::getDiagramBBS(bool wln) {
                for (i = 0; i < (int) connections.size(); i++) {
                        //script += LineNumber(wln, lnNmbr);
                        //script += "connect ";
-                       int id = connections[i];
-                       GObjectController *control = _controllers[id];
-                       GConnectorModel *model = (GConnectorModel*) control->getModel();
+                       int                 id          = connections[i];
+                       GObjectController   *control    = _controllers[id];
+                       GConnectorModel     *model      = (GConnectorModel*) control->getModel();
 
 
                        //Connection info
-                       GPortModel *start = model->getStartPort();
-                       GBoxModel *startBox = start->getParentBox();
+                       GPortModel          *start      = model->getStartPort();
+                       GBoxModel           *startBox   = start->getParentBox();
 
                        GPortModel *end = model->getEndPort();
                        GBoxModel *endBox = end->getParentBox();
@@ -1555,7 +1539,6 @@ std::string wxVtkSceneManager::getDiagramBBS(bool wln) {
                        int id = execBoxes[i];
                        GObjectController *control = _controllers[id];
                        GBlackBoxModel *model = (GBlackBoxModel*) control->getModel();
-
                        script += model->getBBTKName();
                        script += "\n";
                }
@@ -1984,6 +1967,9 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream)
                        if (line == "# - BBTKGEditor v 1.4 BBG BlackBox Diagram file") {
                                version = line.substr(18, 3);
                        }
+            if (line == "# - BBTKGEditor v 1.5 BBG BlackBox Diagram file") {
+                version = line.substr(18, 3);
+            }
                } else if (line == "APP_START") {
                        start = true;
                        break;
@@ -1991,7 +1977,8 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream)
        }
 
 
-       if (start) {
+       if (start)
+    {
 
                if ((version != "1.0") && (version != "1.1")) {
                        getCleanLine(inputStream, line);//CATEGORY:<category of the box>
@@ -2024,10 +2011,12 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream)
                result = strtok(NULL, delims);
                std::string isComplexBox(result);
 
-               if (isComplexBox == "TRUE") {
+               if (isComplexBox == "TRUE")
+        {
                        _isComplexBox = true;
 
-                       if ((version != "1.0") && (version != "1.1")) {
+                       if ((version != "1.0") && (version != "1.1"))
+            {
                                getCleanLine(inputStream, line);//COMPLEXNAME:<name of the complex box>
                                char complexboxnameTmp[255];
                                strcpy(complexboxnameTmp, line.c_str());
@@ -2041,7 +2030,7 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream)
                                result = strtok(packagenameTmp, delims);
                                result = strtok(NULL, delims);
                                SetCbPackageName(result);
-                       }
+                       } // if version !1.0  !1.1
 
                        if(version < "1.4")
                        {
@@ -2058,7 +2047,8 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream)
                                std::istringstream inps(result);
                                inps >> numInputs;
 
-                               for (int i = 0; i < numInputs; i++) {
+                               for (int i = 0; i < numInputs; i++)
+                {
                                        //----------
                                        getCleanLine(inputStream, line);//COMPLEX_PORT
                                        getCleanLine(inputStream, line);//name
@@ -2086,14 +2076,14 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream)
                                        if (version<="1.2")
                                        {
                                                if (zIn==900) zIn=GPOSITION_Z;
-                                       }
+                                       } // if version <=1.2
 
                                        getCleanLine(inputStream, line);//FIN_COMPLEX_PORT
 
                                        configGComBoxInputOutputPort(true, inputPortName, xIn, yIn, zIn);
 
                                } // for input complex box
-                       }
+                       } // if version < 1.4
 
 
 
@@ -2111,7 +2101,8 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream)
                        std::istringstream outps(result);
                        outps >> numOutputs;
 
-                       for (int i = 0; i < numOutputs; i++) {
+                       for (int i = 0; i < numOutputs; i++)
+            {
                                //----------
                                getCleanLine(inputStream, line);//COMPLEX_PORT
                                getCleanLine(inputStream, line);//name
@@ -2140,15 +2131,21 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream)
                                {
                                        if (zIn==900) zIn=GPOSITION_Z;
                                }
-                               
+//EED 2022-01-16
+                if (version<="1.4")
+                {
+                    xIn = xIn*0.70;
+                    yIn = yIn*0.30;
+                }
+
                                getCleanLine(inputStream, line);//FIN_COMPLEX_PORT
 
                                configGComBoxInputOutputPort(false, outputPortName, xIn, yIn, zIn);
 
                        } // for output complex box
+               } // if isComplexBox
 
-               } // complex box
-
+        
                // RaC2012 2nd Hackfest
                if(version >= "1.4")
                {
@@ -2165,13 +2162,11 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream)
                        std::istringstream inps(result);
                        inps >> numInputs;
 
-                       for (int i = 0; i < numInputs; i++) {
-                               //----------
+                       for (int i = 0; i < numInputs; i++)
+            {
                                getCleanLine(inputStream, line);//COMPLEX_PORT
                                getCleanLine(inputStream, line);//name
                                std::string inputPortName(line);
-
-                               //----------
                                getCleanLine(inputStream, line);//xInic:yInic:zInic
                                char coord[80];
                                strcpy(coord, line.c_str());
@@ -2181,7 +2176,6 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream)
                                std::string yInic(result);
                                result = strtok(NULL, delims);//zInic
                                std::string zInic(result);
-
                                double xIn, yIn, zIn;
                                std::istringstream xSt(xInic);
                                xSt >> xIn;
@@ -2189,18 +2183,20 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream)
                                ySt >> yIn;
                                std::istringstream zSt(zInic);
                                zSt >> zIn;
-
                                if (version<="1.2")
                                {
                                        if (zIn==900) zIn=GPOSITION_Z;
                                }
-                               
+//EED 2022-01-16
+                if (version<="1.4")
+                {
+                    xIn = xIn*0.70;
+                    yIn = yIn*0.30;
+                }
                                getCleanLine(inputStream, line);//FIN_COMPLEX_PORT
                                configGComBoxInputOutputPort(true, inputPortName, xIn, yIn, zIn);
-
                        } // for external input
-               }
-
+               }   //      if(version >= "1.4")
 
                //----------
                getCleanLine(inputStream, line);//BOXES:num
@@ -2245,7 +2241,6 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream)
                        std::string yInic(result);
                        result = strtok(NULL, delims);//zInic
                        std::string zInic(result);
-
                        double xIn, yIn, zIn;
                        std::istringstream xSt(xInic);
                        xSt >> xIn;
@@ -2254,13 +2249,16 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream)
                        std::istringstream zSt(zInic);
                        zSt >> zIn;
 
-                       
                        if (version<="1.2")
                        {
                                if (zIn==900) zIn=GPOSITION_Z;
                        }
-                       
-                       
+//EED 2022-01-16
+            if (version<="1.4")
+            {
+                xIn = xIn*0.70;
+                yIn = yIn*0.30;
+            }
                        //----------
                        getCleanLine(inputStream, line);//xEnd:yEnd:zEnd
                        strcpy(coord, line.c_str());
@@ -2283,7 +2281,8 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream)
                        {
                                if (zEn==900) zEn=GPOSITION_Z;
                        }
-                       
+//EED 2022-01-16
+            yEn = yIn-BOX_HEIGHT;
                        
                        bool boxExecutable = false;
                        if (isExec == "TRUE") 
@@ -2321,9 +2320,7 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream)
                                        strcat(result,tmpString.c_str());
                                }
                                std::string value(result);
-
                                bbmod->setValueToInput(name, value);
-
                                getCleanLine(inputStream, line);//PORT o FIN_BOX
                                port = line.substr(0, 4);
                        } // while
@@ -2338,7 +2335,6 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream)
                strcpy(conns, line.c_str());
                result = strtok(conns, delims);
                result = strtok(NULL, delims);
-
                int numConns;
                std::istringstream isCons(result);
                isCons >> numConns;
@@ -2349,7 +2345,6 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream)
                        //----------
                        getCleanLine(inputStream, line);//CONNECTION
                        getCleanLine(inputStream, line);//Startbox.PortName:EndBox.PortName
-
                        char connec[200];
                        strcpy(connec, line.c_str());
                        result = strtok(connec, delims);
@@ -2360,28 +2355,23 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream)
                        std::string nameEndBox(result);
                        result = strtok(NULL, delims);
                        std::string nameEndPort(result);
-
                        int idCon = configGConnetion(nameStartBox, nameStartPort,nameEndBox, nameEndPort);
-
                        if (version != "1.0") {
                                //Readding control points of the manualContour
-                               GConnectorController *tempp             = (GConnectorController*) _controllers[idCon];
-                               GConnectorModel *conMod                 = (GConnectorModel*) tempp->getModel();
-                               vtkGConnectorView *conView              = (vtkGConnectorView*) tempp->getView();
+                               GConnectorController    *tempp          = (GConnectorController*) _controllers[idCon];
+                               GConnectorModel         *conMod         = (GConnectorModel*) tempp->getModel();
+                               vtkGConnectorView       *conView        = (vtkGConnectorView*) tempp->getView();
                                getCleanLine(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; ii < numberOfControlPoints; ii++) {
                                        getCleanLine(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);
@@ -2392,18 +2382,22 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream)
                                        result = strtok(NULL, delims);
                                        std::istringstream isPointZ(result);
                                        isPointZ >> pz;
-               
                                        if (version<="1.2")
                                        {
                                                if (pz==900) pz=GPOSITION_Z;
                                        }
-                                       
+//EED 2022-01-16
+                    if (version<="1.4")
+                    {
+                        px = px*0.70;
+                        py = py*0.30;
+                    }
                                        conMod->getManualContourModel()->InsertPoint_id(ii + 1, px, py, pz);
                                        conView->getManualContourView()->AddPoint();
                                }
-                       }// version !=1.0
+                       }// if version !=1.0
                } // for numConns
-       } // start      
+       } // if start
 }
 //=========================================================================
 
@@ -2621,25 +2615,23 @@ int wxVtkSceneManager::addObjectController(GObjectController* objController) {
 
 //=========================================================================
 
-void wxVtkSceneManager::DuplicateObjects(std::map<int, GObjectController*> objectsMap) {
-
+void wxVtkSceneManager::DuplicateObjects(std::map<int, GObjectController*> objectsMap)
+{
         std::map<int, int> oldIdNewIdBoxes;
         std::vector<int> connections;
-
         std::vector<int> newBoxesID;
-
         std::map<int, GObjectController*>::iterator it;
-        for (it = objectsMap.begin(); it != objectsMap.end(); ++it) {
+        for (it = objectsMap.begin(); it != objectsMap.end(); ++it)
+        {
             GObjectController *cont = it->second;
             int type = cont->getGObjectType();
-
-            if (type == GBLACKBOX) {
+            if (type == GBLACKBOX)
+            {
                 // Copy black box
                 double xInic, yInic, zInic;
                 GBlackBoxModel* copyBox = (GBlackBoxModel*) cont->getModel();
                 copyBox->getInicPoint(xInic, yInic, zInic);
-                int idBox = createGBlackBox(0, 0, copyBox->getBBTKPackage(),
-                        copyBox->getBBTKType());
+                int idBox = createGBlackBox(0, 0, copyBox->getBBTKPackage(), copyBox->getBBTKType());
 
                 int idcB = copyBox->getObjectId();
                 oldIdNewIdBoxes[idcB] = idBox;
@@ -2647,21 +2639,27 @@ void wxVtkSceneManager::DuplicateObjects(std::map<int, GObjectController*> objec
                 GBlackBoxModel* newbox = (GBlackBoxModel*) cont->getModel();
                 newbox->setInicPoint(xInic, yInic, zInic);
                 int num = newbox->getNumInputPorts();
-                for (int j = 0; j < num; j++) {
+                for (int j = 0; j < num; j++)
+                {
                     newbox->setValueToInputPort(j, copyBox->getValueInputPort(j));
-                }
-                newbox->move(xInic + 20, yInic + 20, zInic);
+                } // if  j
+
+// EED 2022-01-16
+//                newbox->move(xInic + 20, yInic + 20, zInic);
+                newbox->move(xInic + 14, yInic + 6, zInic);
+                
                 newbox->notifyObservers(_idManager);
                 newBoxesID.push_back(newbox->getObjectId());
 
             } else if (type == GCONNECTOR) {
                 int idCon = cont->getId();
                 connections.push_back(idCon);
-            }
+            } // if type
 
-        }
+        } // for it
 
-        for (int i = 0; i < (int) connections.size(); i++) {
+        for (int i = 0; i < (int) connections.size(); i++)
+        {
             int objId = connections[i];
             GObjectController *cont = objectsMap[objId];
             GConnectorModel* connectModel = (GConnectorModel*) cont->getModel();
@@ -2696,23 +2694,23 @@ void wxVtkSceneManager::DuplicateObjects(std::map<int, GObjectController*> objec
             tempp->endContourCreation();
             conMod->setEndPort(newEndPort);
             conView->updateStartEndPoints();
-        }
+        } // for i
 
         /// the new selected boxes are the duplicate ones
 
         UnSelectBlackBoxes();
-        for (int i = 0; i < newBoxesID.size(); i++) {
+        for (int i = 0; i < newBoxesID.size(); i++)
+        {
             _selectedObjects.push_back(newBoxesID.at(i));
-        }
+        } // for i
 
-        for (int i = 0; i < (int) _selectedObjects.size(); i++) {
+        for (int i = 0; i < (int) _selectedObjects.size(); i++)
+        {
             int id = _selectedObjects[i];
             GObjectController* cont = _controllers[id];
-
             cont->getView()->setState(SELECTED);
             cont->getModel()->notifyObservers(_idManager);
-
-        }
+        } // for i
     }