From f70f77d64cae0174ae93b3933e781c68e1f4f4c9 Mon Sep 17 00:00:00 2001 From: "eduardo.davila@creatis.insa-lyon.fr" Date: Tue, 16 Dec 2025 17:42:34 +0100 Subject: [PATCH] #3263 Show principal connections --- .../GConnectorModel.cxx | 10 +- .../bbsKernelEditorGraphic/GObjectModel.cxx | 38 +---- .../bbsKernelEditorGraphic/GlobalConstants.h | 13 +- .../bbsVtkGUIEditorGraphic/GBoxController.cxx | 4 +- .../bbsVtkGUIEditorGraphic/vtkGPortView.cxx | 6 +- .../wxVtkSceneManager.cxx | 137 +++++++++++++----- .../bbsWxGUIEditorGraphic/wxVtkSceneManager.h | 1 + 7 files changed, 125 insertions(+), 84 deletions(-) diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.cxx index 19fa703..a51f00c 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.cxx @@ -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 diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.cxx index 70c7ed4..8d9ffaf 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.cxx @@ -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 diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h index fa3823a..6c664ae 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GlobalConstants.h @@ -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; diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBoxController.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBoxController.cxx index ba87c38..4240e94 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBoxController.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBoxController.cxx @@ -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(); diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.cxx index 962b760..3056e32 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.cxx @@ -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 } diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx index 6f8e949..9e36976 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx @@ -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::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::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 (Ysecond; 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; } diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h index cbd2138..fa1fb02 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h @@ -126,6 +126,7 @@ namespace bbtk void configureBaseView(); void registerController(InteractorStyleMaracas *param); void unregisterController(InteractorStyleMaracas *param); + void SelectConnectors(); virtual bool OnChar(); virtual bool OnMouseMove(); -- 2.52.0