* \brief Class bbtk::GObjectModel
*/
-
#include "GObjectModel.h"
namespace bbtk
{
-
-
//=========================================================================
GObjectModel::GObjectModel()
{
-
_xInic = 0;
_yInic = 0;
_zInic = GPOSITION_Z;
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;
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
{
}
//=========================================================================
-
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 = "";
}
//=========================================================================
-
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
_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();
if (GetIndexInSelected(idController) == -1)
{
_selectedObjects.push_back(idController);
+// SelectConnectors();
}
} else if (command == REMOVE_FROM_SELECTED) {
int index = GetIndexInSelected(idController);
{
_selectedObjects.erase(_selectedObjects.begin() + index);
}
+// SelectConnectors();
} else if (command == INIT_CREATION_CONTOUR) {
// JGRR & CM WH
typedef std::map<int , GObjectController*>::iterator TIterator ;
// 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();
}
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
}
//=========================================================================
} else {
sX1=selectRegionX1; sX2=X;
}
-
+
if (Y<selectRegionY1)
{
sY1=Y; sY2=selectRegionY1;
{
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 ) )
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
}
//=========================================================================
-
bool wxVtkSceneManager::OnLeftButtonDown()
{
if (_worldState == INIT_CREATION_CONTOUR)
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();
UnSelectBlackBoxes(); // EED 12/07/2012
_worldState = SELECTING_BOXES;
} // if cont
-
+
if (_worldState==SELECTING_BOXES)
{
crea::wxVTKRenderWindowInteractor *wxVTKiren;
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++)
{
cont->getModel()->notifyObservers(_idManager);
}
}
+ SelectConnectors();
return true;
}