}
//=========================================================================
+
+ 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;
+ }
+
+ //=========================================================================
+//ups1 eed
+ 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);
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)
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];
_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];
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+="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())
}
- for(i = 0; i<connections.size();i++)
+ for(i = 0; i<(int)connections.size();i++)
{
script+="connect ";
int id = connections[i];
script+="\n";
}
- for(i = 0; i<execBoxes.size();i++)
+ 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 idOutputPort = createGComplexBoxOutputPort(outputPortName);
GObjectController *cont = _controllers[idOutputPort];
GBoxModel *cbmod = (GBoxModel*)cont->getModel();
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);
+//EED bbmod->notifyObservers(_idManager);
} // 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(_isComplexBox, 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
}
+ //=========================================================================
+
+ GBlackBoxModel* wxVtkSceneManager::findGBox(std::string boxname)
+ {
+ GBlackBoxModel *boxModel = NULL;
+ GBlackBoxModel *bbMod;
+ std::vector<int> lstB = getBlackBoxes();
+ int idB;
+ int j;
+ for(j = 0;j<(int)lstB.size();j++)
+ {
+ idB = lstB[j];
+ bbMod = (GBlackBoxModel*)_controllers[idB]->getModel();
+ if(_controllers[idB]->getModel()->getBBTKName()==boxname)
+ {
+ boxModel = bbMod;
+ }
+ } // for
+ return boxModel;
+ }
+
+ //=========================================================================
+
+
+ void wxVtkSceneManager::configGConnetion(bool _isComplexBox,
+ std::string nameStartBox, std::string nameStartPort, std::string
+ nameEndBox, std::string nameEndPort)
+ {
+ GPortModel *startP = findGBox(nameStartBox)->getOutputPort(nameStartPort);
+ GPortModel *endP = findGBox(nameEndBox)->getInputPort(nameEndPort);
+
+/*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
+*/
+ int j;
+ 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;
+ }
+
//=========================================================================
std::vector<int> wxVtkSceneManager::getBlackBoxes()
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])
{