]> Creatis software - bbtkGEditor.git/commitdiff
#3263 Show principal connections vtk9itk5wx3-macos
authoreduardo.davila@creatis.insa-lyon.fr <eduardo.davila@creatis.insa-lyon.fr>
Tue, 16 Dec 2025 16:42:34 +0000 (17:42 +0100)
committereduardo.davila@creatis.insa-lyon.fr <eduardo.davila@creatis.insa-lyon.fr>
Tue, 16 Dec 2025 16:42:34 +0000 (17:42 +0100)
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.cxx
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.cxx
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBoxController.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h

index 19fa703f41b418a06a10b751ddb1d5452f0438a6..a51f00ca0847dbc9c6b14c7acf78169c7dd877b8 100644 (file)
@@ -200,14 +200,12 @@ namespace bbtk
        }
 
        //=========================================================================
-
        void GConnectorModel::disconnectConnection()
        {
                if(_startPort!=NULL)
                {
                        _startPort->setConnected(false);                        
                }
-
                if(_endPort!=NULL)
                {
                        _endPort->setConnected(false);
@@ -215,13 +213,10 @@ namespace bbtk
        }
 
        //=========================================================================
-
        void GConnectorModel::save(std::string &content)
        {
                char buffer[50];
-
                content+="CONNECTION\n";
-
                // Connection info
                content+=_startPort->getParentBox()->getBBTKName();
                content+=":";
@@ -243,12 +238,9 @@ namespace bbtk
                        manualPoint *mp = _model->GetManualPoint(i+1);
                        sprintf (buffer, "%f:%f:%f\n", (float)mp->GetX(),(float)mp->GetY(),(float)mp->GetZ() );
                        content+=buffer;
-               }               
+               }       // for i
        }
 
-       //=========================================================================
-
 }  // EO namespace bbtk
-
 // EOF
 
index 70c7ed4d892725c7acff9ea0e0d4ea8e581e58f5..8d9ffaf5254721dd22d0406ff078a70a3c7c7c3a 100644 (file)
@@ -58,17 +58,13 @@ Version:   $Revision$
 *  \brief Class bbtk::GObjectModel 
 */
 
-
 #include "GObjectModel.h"
 
 namespace bbtk
 {
-
-
        //=========================================================================
        GObjectModel::GObjectModel()
        {
-
                _xInic = 0;
                _yInic = 0;
                _zInic = GPOSITION_Z;
@@ -81,56 +77,54 @@ namespace bbtk
        GObjectModel::~GObjectModel()
        {
        }
-       //=========================================================================
 
+       //=========================================================================
        void GObjectModel::getInicPoint(double& x, double& y, double& z)
        {
                x = _xInic;
                y = _yInic;
                z = _zInic;
        }
-       //=========================================================================
 
+       //=========================================================================
        void GObjectModel::getFinalPoint(double& x, double& y, double& z)
        {
                x = _xFin;
                y = _yFin;
                z = _zFin;
        }
-       //=========================================================================
 
+       //=========================================================================
        void GObjectModel::getCenter(double& x, double& y, double& z)
        {
                x = (_xInic+_xFin)/2;
                y = (_yInic+_yFin)/2;
                z = (_zInic+_zFin)/2;
        }
-       //=========================================================================
 
+       //=========================================================================
        void GObjectModel::setInicPoint(double& x, double& y, double& z)
        {
                _xInic = x;
                _yInic = y;
                _zInic = z;
-               
        }
-       //=========================================================================
 
+       //=========================================================================
        void GObjectModel::setFinalPoint(double& x, double& y, double& z)
        {
                _xFin = x;
                _yFin = y;
                _zFin = z;
        }
-       //=========================================================================
 
+       //=========================================================================
        void GObjectModel::setGObjectType(int gObjectType)
        {
                _gObjectType = gObjectType;
        }
 
        //=========================================================================
-
        int GObjectModel::getGObjectType()
        {
                return _gObjectType;
@@ -142,14 +136,11 @@ namespace bbtk
                if(x>=_xInic && x<=_xFin && y<=_yInic && y>=_yFin)
                {
                        return true;
-               }
-               else
-               {
+               } else {
                        return false;
                }
        }
 
-
     //=========================================================================
     bool GObjectModel::isBoxInsideRectangle(double x1,double y1, double z1,double x2,double y2, double z2)//virtual
     {
@@ -169,49 +160,42 @@ namespace bbtk
        }
 
        //=========================================================================
-
        std::string GObjectModel::getBBTKType()
        {
                return _bbtkType; 
        }
 
        //=========================================================================
-
        void GObjectModel::setBBTKType(std::string obtype)
        {
                _bbtkType = obtype;
        }
 
        //=========================================================================
-               
        std::string GObjectModel::getBBTKName()
        {
                return _bbtkName;
        }
 
        //=========================================================================
-
        void GObjectModel::setBBTKName(std::string obname)
        {
                _bbtkName = obname;
        }
 
        //=========================================================================
-       
        std::string GObjectModel::getBBTKDescription()
        {
                return _bbtkDescription;
        }
        
        //=========================================================================
-       
        void GObjectModel::setBBTKDescription(std::string obdescription)
        {
                _bbtkDescription = obdescription;
        }
        
        //=========================================================================
-
        std::string GObjectModel::getStatusText()//virtual
        {
                std::string virt = "";
@@ -219,29 +203,23 @@ namespace bbtk
        }
 
        //=========================================================================
-
        int GObjectModel::getObjectId()
        {
                return _objectId;
        }
 
        //=========================================================================
-       
        void GObjectModel::setObjectId(int id)
        {
                _objectId=id;
        }
 
        //=========================================================================
-
        void GObjectModel::save(std::string &content)
        {
                //virtual
        }
-       
-       //=========================================================================
-
-}  // EO namespace bbtk
 
+}// EO namespace bbtk
 // EOF
 
index fa3823ae9d116636369df0e701bb8b0a8f0b6088..6c664aedc28f2773e4384e111f181aa0037c6821 100644 (file)
@@ -119,7 +119,7 @@ namespace bbtk {
     const int STATE_CONNECTION_HIGHLIGHTED      =   221;
     const int STATE_CONNECTION_NORMAL           =   222;
     const double CONNECTION_HIGHLIGHTED         =   1;
-    const double CONNECTION_NORMAL              =   0.1;
+    const double CONNECTION_NORMAL              =   0.15;
 
 
        //// COLORS (object_state_(R|G|B))
@@ -153,9 +153,14 @@ namespace bbtk {
 
        //Object Fill colors
 
-       const double BOXFILL_NH_R                               =       0.5;
-       const double BOXFILL_NH_G                               =       0.35;
-       const double BOXFILL_NH_B                               =       0.15;
+//     const double BOXFILL_NH_R                               =       0.5;
+//     const double BOXFILL_NH_G                               =       0.35;
+//     const double BOXFILL_NH_B                               =       0.15;
+
+    const double BOXFILL_NH_R                =    0.5;
+    const double BOXFILL_NH_G                =    0.35;
+    const double BOXFILL_NH_B                =    0.5;
+
 
        const double COMPLEXINPUTPORTFILL_NH_R  =       0.8;
        const double COMPLEXINPUTPORTFILL_NH_G  =       0.1;
index ba87c386f5b6430d8d937386ac1ba8636591cb86..4240e9451d2e372f11c06d0ec898a418553d7b2a 100644 (file)
@@ -172,8 +172,8 @@ bool GBoxController::OnMouseMove()
 bool GBoxController::OnLeftButtonDown()
 {
 //        _objHasBeenMoved = false;
-    _isLeftClickDown = true;
-    bool ok=true;
+            _isLeftClickDown    = true;
+    bool    ok                  = true;
     int X,Y;
     crea::wxVTKRenderWindowInteractor *_wxVTKiren;
     _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
index 962b7607d683b152fd1515567f1e4ed0e19a5507..3056e321fff0b46e5f295906704df0f64cf9dcf3 100644 (file)
@@ -182,9 +182,11 @@ namespace bbtk {
             if ( portm->isConnected( ) ) {
                                rgb[0]=0.15; rgb[1]=0.15; rgb[2]=0.15;
             } else if ( portm->isValueSet( ) ) {
-                               rgb[0]=0.55; rgb[1]=0.25; rgb[2]=0.25;
+//                rgb[0]=0.55; rgb[1]=0.25; rgb[2]=0.25;
+                               rgb[0]=1.00; rgb[1]=0.25; rgb[2]=0.25;
             } else {
-                               rgb[0]=0.45; rgb[1]=0.45; rgb[2]=0.45;
+//                             rgb[0]=0.45; rgb[1]=0.45; rgb[2]=0.45;
+                rgb[0]=0.8; rgb[1]=0.8; rgb[2]=0.8;
             } // if portm
         } // if  _state
        }
index 6f8e949cadad1549995edf5a32ca66324472dcac..9e36976215b2a96807d000c0fe78bef7ed00c2a5 100644 (file)
@@ -149,9 +149,13 @@ void wxVtkSceneManager::configureBaseView()
        _baseView->GetRenderer()->GetActiveCamera()->ParallelProjectionOn();
        _baseView->GetRenderer()->ResetCamera(-100, 100, -100, 100, -1000, 1000);
        _baseView->GetRenderer()->GetActiveCamera()->Zoom(20);
-       _baseView->GetRenderer()->SetBackground( 0.55 , 0.55 , 0.75 );
-    _baseView->GetRenderer()->SetBackground2( 0.77 , 0.77 , 0.99 );
-       _baseView->GetRenderer()->GradientBackgroundOn();
+    
+//     _baseView->GetRenderer()->SetBackground( 0.55 , 0.55 , 0.75 );
+//    _baseView->GetRenderer()->SetBackground2( 0.77 , 0.77 , 0.99 );
+//    _baseView->GetRenderer()->GradientBackgroundOn();
+    _baseView->GetRenderer()->SetBackground( 0.4 , 0.4 , 0.4 );
+       _baseView->GetRenderer()->GradientBackgroundOff();
+    
        // Actos Port_Text
        _textActor = vtkTextActor3D::New();
 //     _textActor = vtkTextActor::New();
@@ -698,6 +702,7 @@ void wxVtkSceneManager::update(int idController, int command)
                        if (GetIndexInSelected(idController) == -1) 
                        {
                                _selectedObjects.push_back(idController);
+//                SelectConnectors();
                        }
                } else if (command == REMOVE_FROM_SELECTED) {
                        int index = GetIndexInSelected(idController);
@@ -705,6 +710,7 @@ void wxVtkSceneManager::update(int idController, int command)
                        {
                                _selectedObjects.erase(_selectedObjects.begin() + index);
                        }
+//            SelectConnectors();
                } else if (command == INIT_CREATION_CONTOUR) {
                 // JGRR & CM WH
                 typedef std::map<int , GObjectController*>::iterator TIterator ;
@@ -797,13 +803,10 @@ void wxVtkSceneManager::update(int idController, int command)
                                         // Change element to connected state
                                         obc->getView()->setState(HIGHLIGHTED);
                                     }
-
-                                }
-                                // EO JGRR CM                                
-                    
+                                }//for c_it
+                                // EO JGRR CM
                                                                _parent->saveTempandUpdate("create connection");
-                       }
-
+                       } // if GPORT
                        manualConnectorContourController        *manCont        = ((GConnectorController*) cont)->getManualContourController();
                        manualConnectorContourView                      *connView       = (manualConnectorContourView*) manCont->GetManualViewBaseContour();
                                      
@@ -820,7 +823,79 @@ void wxVtkSceneManager::update(int idController, int command)
                        }
                        connView->Refresh();          
                }
-       }
+       } // if (command != NO_COMMAND)
+}
+
+//EED 2025-11-29
+//=========================================================================
+void  wxVtkSceneManager::SelectConnectors()
+{
+    std::map<int, GObjectController*>::iterator it;
+    GObjectController                           *desc;
+    int                                         type;
+//  int                                         state;
+    int                                         id;
+    int                                         iSelected;
+    GConnectorModel                             *connectorModel;
+    vtkGConnectorView                           *connectorView;
+    GObjectController                           *cont;
+    
+    bool                                        ok;
+    std::string                                 possibleNameAA;
+    GBoxModel                                   *modelBoxStart;
+    GBoxModel                                   *modelBoxEnd;
+    std:string                                  boxNameStart;
+    std::string                                 boxNameEnd;
+
+            for (it = _controllers.begin(); it != _controllers.end(); ++it)
+            {
+                desc    = it->second;
+                type    = desc->getGObjectType();
+                // Select Connector
+                if ( type==GCONNECTOR)
+                {
+                    desc->getView()->setState(STATE_CONNECTION_NORMAL);
+                    id = desc->getModel()->getObjectId();
+                    desc->getModel()->notifyObservers( id , CONNECTION_NORMAL );
+                } // if type GCONNECTOR
+            } // for it
+            
+            for ( iSelected = 0; iSelected < (int) _selectedObjects.size(); iSelected++)
+            {
+                id              = _selectedObjects[iSelected];
+                cont            = _controllers[id];
+                possibleNameAA  = cont->getModel()->getBBTKName();
+                std::transform( possibleNameAA.begin(),possibleNameAA.end(),possibleNameAA.begin(), ::toupper );
+                for (it = _controllers.begin(); it != _controllers.end(); ++it)
+                {
+                    desc    = it->second;
+                    type    = desc->getGObjectType();
+                    // Select Connector
+                    if ( type==GCONNECTOR)
+                    {
+                        connectorModel  = (GConnectorModel*) (desc->getModel());
+                        connectorView   = (vtkGConnectorView*) (desc->getView());
+                        ok              = false;
+                        //start
+                        modelBoxStart   = connectorModel->getStartPort()->getParentBox();
+                        boxNameStart    = modelBoxStart->getBBTKType() +":"+ modelBoxStart->getBBTKName();
+                        std::transform( boxNameStart.begin(),boxNameStart.end(),boxNameStart.begin(),::toupper);
+                        if  ( (int)(boxNameStart.find(possibleNameAA)) >= 0 ) { ok= true;}
+                        //end
+                        modelBoxEnd     = connectorModel->getEndPort()->getParentBox();
+                        boxNameEnd      = modelBoxEnd->getBBTKType() +":"+ modelBoxEnd->getBBTKName();
+                        std::transform( boxNameEnd.begin(),boxNameEnd.end(),boxNameEnd.begin(),::toupper);
+                        if  ( (int)(boxNameEnd.find(possibleNameAA)) >= 0 ) { ok= true; }
+                        //
+                        if (ok==true)
+                        {
+                            desc->getView()->setState(STATE_CONNECTION_HIGHLIGHTED);
+                        } // if ok
+                        id = desc->getModel()->getObjectId();
+                        desc->getModel()->notifyObservers( id , COMMAND_CONNECTION_HIGHLIGHTED );
+                    } //if type== 2 GCONNECTOR   //  GlobalConstants.h
+                } // for it
+            } // for _selectedObjects
 }
 
 //=========================================================================
@@ -925,7 +1000,7 @@ bool wxVtkSceneManager::OnMouseMove()
         } else {
             sX1=selectRegionX1; sX2=X;
         }
-
+        
         if (Y<selectRegionY1)
         {
             sY1=Y; sY2=selectRegionY1;
@@ -944,7 +1019,7 @@ bool wxVtkSceneManager::OnMouseMove()
         {
             desc    = it->second;
             type    = desc->getGObjectType();
-            state   = desc->getView()->getState();
+//            state   = desc->getView()->getState();
             if ( (type==GBLACKBOX) || (type==GCOMPLEXINPUTPORT) || (type==GCOMPLEXOUTPUTPORT) )
             {
                 if ( desc->getView()->isBoxInsideRectangle( sX1 , sY1,sX2 , sY2 ) )
@@ -952,23 +1027,11 @@ bool wxVtkSceneManager::OnMouseMove()
                     desc->getView()->setState(SELECTED);
                     id = desc->getModel()->getObjectId();
                     desc->getModel()->notifyObservers( id , ADD_TO_SELECTED );
-                    
-//EED 2025-11-29
-                    // Aqui toca seleccionar los connector input y output de esta caja
-                    
-                }
+                } // if isBoxInsideRectangle
             } // if type == 1
         } // for it
         
-//EED 2025-11-29
-        for (int i = 0; i < (int) _selectedObjects.size(); i++)
-        {
-            int id = _selectedObjects[i];
-            GObjectController* cont = _controllers[id];
-            std::string name = cont->getModel()->getBBTKName();
-            printf("EED wxVtkSceneManager::OnMouseMove  %d  %s\n", id, name.c_str() );
-        }
-
+        SelectConnectors();
         
     } //  if _worldState
     
@@ -989,7 +1052,6 @@ bool wxVtkSceneManager::OnMouseMove()
 }
 
 //=========================================================================
-
 bool wxVtkSceneManager::OnLeftButtonDown() 
 {
        if (_worldState == INIT_CREATION_CONTOUR) 
@@ -1022,15 +1084,15 @@ bool wxVtkSceneManager::OnLeftButtonDown()
                        UnSelectBlackBoxes();
                } // isOverPort
        } else { //_worldState
-               _startDragging          = true;
-               int shiftkey            = _vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey();
-               int ctrlkey                     = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey();
-               ctrlkey                         = ctrlkey + shiftkey;
-               GObjectController *cont = GetGBoxControlerPointedByMouse();
-               if (cont != NULL)
+               _startDragging                  = true;
+               int shiftkey                    = _vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey();
+               int ctrlkey                             = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey();
+               ctrlkey                                 = ctrlkey + shiftkey;
+               GObjectController *controller   = GetGBoxControlerPointedByMouse();
+               if (controller != NULL)
         {
-            _worldState        = DRAG_OBJECTS;
-                       int state = cont->getView()->getState();
+            _worldState     = DRAG_OBJECTS;
+                       int state       = controller->getView()->getState();
                        if ((ctrlkey == 0) && (state == HIGHLIGHTED))
             {
                                UnSelectBlackBoxes();
@@ -1039,7 +1101,7 @@ bool wxVtkSceneManager::OnLeftButtonDown()
                        UnSelectBlackBoxes();  // EED 12/07/2012
             _worldState        = SELECTING_BOXES;
                } // if cont
-        
+                
         if (_worldState==SELECTING_BOXES)
         {
             crea::wxVTKRenderWindowInteractor *wxVTKiren;
@@ -1047,7 +1109,7 @@ bool wxVtkSceneManager::OnLeftButtonDown()
             wxVTKiren->GetEventPosition(selectRegionX1, selectRegionY1);
         } // if _worldState SELECTING_BOXES
         
-        if (_worldState==DRAG_OBJECTS)
+        if (_worldState == DRAG_OBJECTS)
         {
             for (int i = 0; i < (int) _selectedObjects.size(); i++)
             {
@@ -1077,6 +1139,7 @@ bool wxVtkSceneManager::OnLeftButtonUp()
                        cont->getModel()->notifyObservers(_idManager);
                }
        }
+    SelectConnectors();
        return true;
 }
 
index cbd2138afcda13175ad43be1831c6d2605f12d29..fa1fb02a45e378a8a501dd6d4d4d5c73091a372d 100644 (file)
@@ -126,6 +126,7 @@ namespace bbtk
                void configureBaseView();
                void registerController(InteractorStyleMaracas *param);
                void unregisterController(InteractorStyleMaracas *param);
+        void SelectConnectors();
 
                virtual bool OnChar();
                virtual bool OnMouseMove();