#include "wxVtkSceneManager.h"
+ #include <vtkPolygon.h>
+ #include <vtkUnstructuredGrid.h>
+
+
namespace bbtk
{
//=========================================================================
wxVtkSceneManager::wxVtkSceneManager(wxGEditorTabPanel *parent, wxVtk3DBaseView *baseView,int idManager)
{
- _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 )
{
registerController(this);
}
- _idConnectionInCreation=-1;
- _contLastId=0;
+ _idConnectionInCreation = -1;
+ _contLastId = 0;
}
_baseView->GetRenderer()->SetBackground(0.9,0.9,0.9);
_baseView->GetRenderer()->GradientBackgroundOff();
_baseView->Refresh();
+
+ // Actos Port_Text
+ _textActor = vtkTextActor3D::New();
+ _textActor->SetPosition( -9999 , -9999 , 900 );
+ _textActor->SetInput( "<void>" );
+ _textActor->GetTextProperty()->SetFontSize(40);
+ _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;
+/*
+ vtkCellArray *strip = vtkCellArray::New();
+ vtkPolyData *pdFill = vtkPolyData::New();
+ _fillObjectActor = vtkActor::New();
+ _fillPolyMapper = vtkPolyDataMapper::New();
+*/
+printf ("EED wxVtkSceneManager::configureBaseView 1...\n");
+
+ vtkPolygon *aPolygon = vtkPolygon::New();
+ _fillObjectActor = vtkActor::New();
+
+ _pts = vtkPoints::New();
+//ups4 EED Borrame
+ _pts->SetNumberOfPoints(7);
+ _pts->InsertPoint(0, xInic , yInic , zInic );
+ _pts->InsertPoint(1, xInic+50 , yInic , zInic );
+ _pts->InsertPoint(2, xInic+50 , yInic+50 , zInic );
+ _pts->InsertPoint(3, xInic+25 , yInic+50 , zInic );
+ _pts->InsertPoint(4, xInic+20 , yInic+55 , zInic );
+ _pts->InsertPoint(5, xInic+15 , yInic+50 , zInic );
+ _pts->InsertPoint(6, xInic , yInic+50 , zInic );
+
+/*
+ strip->InsertNextCell(8);
+ strip->InsertCellPoint(0);
+ strip->InsertCellPoint(1);
+ strip->InsertCellPoint(2);
+ strip->InsertCellPoint(0);
+ strip->InsertCellPoint(3);
+ pdFill->SetPoints( _pts );
+ pdFill->SetStrips( strip );
+ _fillPolyMapper->SetInput(pdFill);
+*/
+
+printf ("EED wxVtkSceneManager::configureBaseView 2...\n");
+
+ aPolygon->GetPointIds()->SetNumberOfIds(7);
+ aPolygon->GetPointIds()->SetId(0, 0);
+ aPolygon->GetPointIds()->SetId(1, 1);
+ aPolygon->GetPointIds()->SetId(2, 2);
+ aPolygon->GetPointIds()->SetId(3, 3);
+ aPolygon->GetPointIds()->SetId(4, 4);
+ aPolygon->GetPointIds()->SetId(5, 5);
+ aPolygon->GetPointIds()->SetId(6, 6);
+
+printf ("EED wxVtkSceneManager::configureBaseView 3...\n");
+
+ vtkUnstructuredGrid *aPolygonGrid = vtkUnstructuredGrid::New();
+ aPolygonGrid->Allocate(1, 1);
+ aPolygonGrid->InsertNextCell(aPolygon->GetCellType(), aPolygon->GetPointIds());
+ aPolygonGrid->SetPoints(_pts);
+printf ("EED wxVtkSceneManager::configureBaseView 4...\n");
+ _aPolygonMapper = vtkDataSetMapper::New();
+ _aPolygonMapper->SetInput(aPolygonGrid);
+ _fillObjectActor->SetMapper(_aPolygonMapper);
+printf ("EED wxVtkSceneManager::configureBaseView 5...\n");
+ _fillObjectActor->GetProperty()->SetColor(PORTFILL_NH_R,PORTFILL_NH_G,PORTFILL_NH_B);
+ _aPolygonMapper->Modified();
+
+ _baseView->GetRenderer()->AddActor( _fillObjectActor );
+printf ("EED wxVtkSceneManager::configureBaseView fin...\n");
}
//=========================================================================
+
+ 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()
{
- _worldState = NOTHING_HAPPENS;
- 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
_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);
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;
_baseView->TransCoordScreenToWorld(xx,yy,zz);
model->setInicPoint(xx,yy,zz);
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;
_baseView->TransCoordScreenToWorld(xx,yy,zz);
model->setInicPoint(xx,yy,zz);
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->notifyObservers(_idManager);
- int newId = addObjectController(controller);
+ addObjectController(controller);
return (GPortController*)controller;
}
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);
{
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)
bool wxVtkSceneManager::OnMouseMove()
{
int X,Y;
+ bool okStatusMessage = false;
+ bool okPortMessage = false;
wxVTKRenderWindowInteractor *wxVTKiren;
wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
wxVTKiren->GetEventPosition(X,Y);
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];
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 , pz+2 );
+
+ // FillPortText
+ px=px-35;
+ py=py-2;
+/*
+ _pts->SetPoint(0, px , py , 900+1 );
+ _pts->SetPoint(1, px+150 , py , 900+1 );
+ _pts->SetPoint(2, px+150 , py+7 , 900+1 );
+ _pts->SetPoint(3, px-150+40 , py+7 , 900+1 );
+ _pts->SetPoint(4, px-150+40-5 , py+7+5 , 900+1 );
+ _pts->SetPoint(5, px-150+40-10 , py+7 , 900+1 );
+ _pts->SetPoint(6, px , py+7 , 900+1 );
+*/
+ _fillObjectActor->SetScale(1);
+ _fillObjectActor->SetPosition(px,py,1);
+ _aPolygonMapper->Modified();
+ } // if GPORT
+
+ } // for controllers it
+ }
+ }
+//ups4 EED Borrame
+ if (okStatusMessage==false)
+ {
+ updateStatusBar("");
+ }
+
+ if (okPortMessage==false)
+ {
+ _textActor->SetScale(0.0001);
+ _fillObjectActor->SetScale(0.0001);
}
+
return 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];
{
_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];
}
- 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];
{
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];
{
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();
}
//=========================================================================
+ 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];
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;
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;
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());
+ AddControlerToBeRemove( &controllersToRemove, conMod->getObjectId() );
}
- for(int i = 0;i<controllersToRemove.size();i++)
+
+ std::map<int,GObjectController*>::iterator it;
+
+ for(int i = 0;i<(int)controllersToRemove.size();i++)
{
- int id = controllersToRemove[i];
- GObjectController *cont = _controllers[id];
+ int key = controllersToRemove[i];
+ it = _controllers.find( key );
+ GObjectController *cont = _controllers[ key ];
if(cont!=NULL)
{
cont->removeFromScene();
unregisterController((InteractorStyleMaracas*)cont);
- _controllers.erase(id);
- }
- }
-
-
+ _controllers.erase(it);
+ }//if
+ }// for
}
//=========================================================================
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)
{
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];
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();
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];
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];
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)
{
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;
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];
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();
script+="\n";
}
}
+ script+="\n";
}
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];
}
}
- for(i = 0; i<execBoxes.size();i++)
+ script+="\n";
+
+ for(i = 0; i<(int)execBoxes.size();i++)
{
script+="exec ";
int id = execBoxes[i];
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);
+
+//ups3 EED Borrame
+// int idInputPort = createGComplexBoxInputPort(inputPortName);
+// GObjectController *cont = _controllers[idInputPort];
+// GBoxModel *cbmod = (GBoxModel*)cont->getModel();
+// cbmod->setInicPoint(xIn,yIn,zIn);
+// cbmod->notifyObservers(_idManager);
+
+
} // for input complex box
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);
+
+//ups 3 EED Borrame
+// int idOutputPort = createGComplexBoxOutputPort(outputPortName);
+// GObjectController *cont = _controllers[idOutputPort];
+// GBoxModel *cbmod = (GBoxModel*)cont->getModel();
+// cbmod->setInicPoint(xIn,yIn,zIn);
+// cbmod->notifyObservers(_idManager);
+
} // for output complex box
} // complex box
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);
- }
- else if(isExec=="FALSE")
- {
- bbmod->setExecutable(false);
+ boxExecutable= true;
}
+
+ 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();
+
+
+//ups2 eed
+// 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);
+
//----------
getline(inputStream,line);//PORT o FIN_BOX
port=line.substr(0,4);
} // while
- bbmod->notifyObservers(_idManager);
- } // boxes
+//EED bbmod->notifyObservers(_idManager);
+ } // for boxes
/// CONNECTIONS
//----------
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++)
+ configGConnetion(nameStartBox, nameStartPort, nameEndBox, nameEndPort);
+//ups 3 EED Borrame
+/*
+ std::vector<int> lstB = getBlackBoxes();
+ GPortModel *startP = NULL;
+ GPortModel *endP = NULL;
+ int j;
+ for(j = 0;j<lstB.size();j++)
{
int idB = lstB[j];
GBlackBoxModel *bbMod = (GBlackBoxModel*)_controllers[idB]->getModel();
if(startP==NULL)
{
std::vector<int> lstInputs = getComplexInputPorts();
- for(int j = 0;j<lstInputs.size();j++)
+ for(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);
- }
- }
- }
+ } // if
+ } // for
+ } // if
if(endP==NULL)
{
std::vector<int> lstOutputs = getComplexOutputPorts();
- for(int j = 0;j<lstOutputs.size();j++)
+ for(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);
- }
- }
- }
+ } // if
+ } // for
+ } // if endP
} // complex box
int idCon = createGConnector(startP);
tempp->endContourCreation();
conMod->setEndPort(endP);
conView->updateStartEndPoints();
-
+ */
} // for numConns
+
} // start
}
+ //=========================================================================
+
+
+
+ //=========================================================================
+ 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)
+ {
+ 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
+
+ return boxModel;
+ }
+
+ //=========================================================================
+
+
+ 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 );
+
+/*ups5 EED Borrame
+ std::vector<int> lstB = getBlackBoxes();
+ int j;
+ for(j = 0;j<(int)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);
+ }
+ } // for
+
+ if(_isComplexBox)
+ {
+ if(startP==NULL)
+ {
+ std::vector<int> lstInputs = getComplexInputPorts();
+ for(j = 0;j<(int)lstInputs.size();j++)
+ {
+ int idB = lstInputs[j];
+ GBoxModel *cbMod = (GBoxModel*)_controllers[idB]->getModel();
+ if(_controllers[idB]->getModel()->getBBTKName()==nameStartBox)
+ {
+ startP = cbMod->getOutputPort(nameStartPort);
+ } // if
+ } // for
+ } // if
+
+ if(endP==NULL)
+ {
+ std::vector<int> lstOutputs = getComplexOutputPorts();
+ for(j = 0;j<(int)lstOutputs.size();j++)
+ {
+ int idB = lstOutputs[j];
+ GBoxModel *cbMod = (GBoxModel*)_controllers[idB]->getModel();
+ if(_controllers[idB]->getModel()->getBBTKName()==nameEndBox)
+ {
+ endP = cbMod->getInputPort(nameEndPort);
+ } // if
+ } // for
+ } // if endP
+ } // complex box
+ */
+
+ 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;
+ }
//=========================================================================
{
int ID = cont->getId();
mapSelected[ID]=cont;
- }
-
+ }
}
}
return mapSelected;
}
- 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];
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])
{
}
- 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])
{